솔루션 function solution(n) { let answer = []; for (let i = 1; i a - b); } 솔루션 function solution2(n) { const answer = Array(n) .fill(0) .map((v, i) => v + i + 1) .filter((v) => n % v === 0); consol..
솔루션 const solution = (message) => { const answer = message.split("").length * 2; console.log(answer); return answer; }; 솔루션 const solution2 = (message) => { const answer = [...message].length * 2; console.log(answer); return answer; }; 솔루션 const solution3 = (message) => { const answer = message.length * 2; console.log(answer); return answer; };
솔루션 const solution = (array) => { const answer = Math.max(...array); console.log(answer); const index = array.indexOf(answer); console.log(index); return [answer, index]; };
솔루션 const solution = (my_string) => { const answer = eval(my_string); console.log(answer); return answer; };
솔루션 const solution = (s1, s2) => { const answer = s1.filter((v) => s2.includes(v)).length; console.log(answer); return answer; }; 솔루션 function solution2(s1, s2) { let answer = 0; for (var i = 0; i < s1.length; i++) { for (var j = 0; j < s2.length; j++) { if (s1[i] === s2[j]) answer++; } } console.log(answer); return answer; }
솔루션 const solution = (num, k) => { const answer = [...("" + num)].findIndex((v) => +v === k); console.log(answer); return answer === -1 ? -1 : answer + 1; }; 솔루션 const solution2 = (num, k) => { const answer = num.toString(); if (answer.includes(k)) { return answer.indexOf(k) + 1; } else { return -1; } };
솔루션 const solution = (n, numlist) => { const answer = []; for (let i = 0; i { const answer = numlist.filter((v) => v % n === 0); console.log(answer); return answer; };
솔루션 const solution = (n) => { const answer = [...("" + n)].map((v) => +v).reduce((x, y) => x + y, 0); console.log(answer); return answer; }; 솔루션 const solution2 = (n) => { const answer = n .toString() .split("") .reduce((x, y) => x + Number(y), 0); console.log(answer); return answer; };