Skip to content

Commit 4e207e3

Browse files
adding 60
1 parent dd64a67 commit 4e207e3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,3 +2203,37 @@ const maximumScore = (titleHand) => {
22032203
22042204
---
22052205
**[⬆ Back to Top](#header)**
2206+
2207+
2208+
2209+
##### 60.Create a function that takes an array as an argument and returns true or false depending on whether the average of all elements in the array is a whole number or not.
2210+
2211+
2212+
```js
2213+
const isAvgWhole = (arr) =>{
2214+
//Write Your solution Here
2215+
};
2216+
2217+
console.log(isAvgWhole([1, 3])); // true
2218+
console.log(isAvgWhole([1, 2, 3, 4])); // false
2219+
console.log(isAvgWhole([1, 5, 6]));// true
2220+
console.log(isAvgWhole([1, 1, 1]));// true
2221+
console.log(isAvgWhole([9, 2, 2, 5]));// false
2222+
2223+
```
2224+
2225+
<details><summary style="cursor:pointer">Solution</summary>
2226+
2227+
```js
2228+
const isAvgWhole = (arr) =>{
2229+
let sum = 0;
2230+
for (i in arr){sum += arr[i]}
2231+
if (sum%(arr.length)===0){return true}
2232+
return false
2233+
}
2234+
```
2235+
2236+
</details>
2237+
2238+
---
2239+
**[⬆ Back to Top](#header)**

0 commit comments

Comments
 (0)