Created
September 18, 2023 09:31
-
-
Save 1travelintexan/b7df83b5dabc18ad4701493e2cc8912c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filter_list(l) { | |
return l.filter((elem)=> typeof elem === 'number') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
function procedure(n){ | |
2 | |
const arr = [] | |
3 | |
for(let i=1; i<=100; i++){ | |
4 | |
if(i % n ===0){ | |
5 | |
arr.push(i) | |
6 | |
} | |
7 | |
} | |
8 | |
const sumsArr = arr.map((num)=>{ | |
9 | |
const strNum = num.toString() | |
10 | |
const firstNum = Number(strNum[0]) | |
11 | |
let secNum = 0 | |
12 | |
if(strNum[1]){ | |
13 | |
secNum = Number(strNum[1]) | |
14 | |
} | |
15 | |
const sum = firstNum + secNum | |
16 | |
return sum | |
17 | |
}) | |
18 | |
const total = sumsArr.reduce((acc, curr)=>{ | |
19 | |
return curr + acc | |
20 | |
}, 0) | |
21 | |
| |
22 | |
return total | |
23 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function repeatStr (n, s) { | |
return s.repeat(n) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uniqueInOrder=function(iterable){ | |
let arr = [] | |
for(let i=0; i<iterable.length;i++){ | |
if(iterable[i] !== iterable[i+1]){ | |
arr.push(iterable[i]) | |
} | |
} | |
return arr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment