Created
October 13, 2020 18:10
-
-
Save satjava/accd437da577aed298ce58d95a5fa6a8 to your computer and use it in GitHub Desktop.
part1-question5
This file contains hidden or 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
let abc = () => { | |
let arr = Array.apply(0, Array(30)) | |
.map(function(val, index) { | |
return index; | |
}); | |
let err = 0 | |
let a = new Promise((resolve, reject) => { | |
arr = arr.map(val => { | |
if (val% 2== 0) { | |
return (val * val) | |
} else { | |
return false | |
} | |
}); | |
resolve(arr) | |
}) | |
a.then((val) => { | |
let errcount = arr.filter(i => i == false).length | |
let resultArray = arr.filter(i => i != false) | |
console.log('Number of errors' , errcount); | |
console.log('The resultant array', resultArray) | |
console.log('Number of objects in the resultant array', val.length) | |
}) | |
} | |
abc(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment