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
const getCount = (str) => str.split('').filter((ele) => 'aeiou'.includes(ele)).length |
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
function processData(input) { | |
const inputArr = input.split('\n') | |
let num = parseInt(inputArr[0]) | |
let contacts = {}; | |
for (let i = 1; i <= num; i++) { | |
let temp = inputArr[i].split(' ') | |
contacts[temp[0]] = temp[1] | |
} | |
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
function processData(input) { | |
let splitInput = input.split('\n').slice(1); | |
splitInput.forEach((str) => { | |
let even = ''; | |
let odd = ''; | |
for(let i = 0; i < str.length; i++) { | |
i%2 === 0? even += str[i] : odd += str[i] | |
} | |
console.log(`${even} ${odd}`) |
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
function eachCons(array, n) { | |
let newArr = []; | |
let childArr; | |
for(let i = 0; i < array.length; i++) { | |
childArr = array.slice(i, n + i) | |
if(childArr.length === n) { | |
newArr.push(childArr) | |
} | |
} | |
return newArr |
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
function spinWords(string){ | |
const arr = string.split(' '); | |
let result = ''; | |
arr.map((str, i) => { | |
if (str.length >= 5){ | |
arr[i] = str.split('').reverse().join(''); | |
} else { | |
arr[i] = str; | |
} | |
result = arr.join(' '); |
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
function simpleArraySum(ar) { | |
let sum = 0 | |
ar.map((num) => { | |
sum += num; | |
}); | |
return sum; | |
} |