code challenges javascript
You can find many exercises at here: > https://www.jschallenger.com There's also an online compiler on this site. // iury.landin
javascript coding challenges with solutions
Q) Find all the duplicated values in given array. //input : [1,2,4,3,2,1,3] //output: [1,2,3] Solution) var findDuplicates = (arr) => { let newArr = arr.filter((e,i ,a) => a.indexOf(e) != a.lastIndexOf(e) ) return [...new Set(newArr)]; }; let nums = [1,2,4,3,2,1,3]; let reqArr = findDuplicates(nums); console.log(reqArr);