솔루션 const solution = (a, b, c) => { let answer = 0; for (let i = a; i +v === c).length; } console.log(answer); return answer; };
솔루션 const solution = (my_string) => { const str = [...my_string]; let answer = []; for (let i = 0; i < str.length; i++) { if (!answer.includes(str[i])) { answer.push(str[i]); } else { continue; } } console.log(answer.join("")); return answer.join(""); }; 솔루션 function solution(my_string) { return [...new Set(my_string)].join(''); } 스프레드 연산자에서 바로 생성자 사용 가능한거 하나 배움 그리고 굳이 split으로 나눌 필요도 없음
솔루션 const solution = (sides) => { const max = Math.max(...sides); const answer = max a + c, 0) - max ? 1 : 2; console.log(answer); return answer; }; 솔루션 const solution = (sides) => { sides = sides.sort((a, b) => a - b); const answer = sides[0] + sides[1] > sides[2] ? 1 : 2; console.log(answer); return answer; };
솔루션 const solution = (array, n) => { const minDiff = Math.min(...array.map((v) => Math.abs(v - n))); console.log(minDiff); const answer = array .sort((a, b) => a - b) .find((a) => Math.abs(a - n) === minDiff); console.log(answer); return answer; }; Math 메서드의 min(최솟값)과 abs(절댓값)을 이용
솔루션 const solution = (order) => { const str = [...("" + order)].filter( (v) => v === "3" || v === "6" || v === "9" ); const answer = str.length; console.log(answer); return answer; }; 솔루션 const solution = (order) => { const answer = [...order.toString().matchAll(/[3|6|9]/g)].length; console.log(answer); return answer; }; 정규식을 이용한 풀이 솔루션 const solution = (order) => { const set = new Set([3, 6, 9]..
솔루션 const solution = (cipher, code) => { const str = [...cipher]; const answer = str.reduce( (a, c, i) => ((i + 1) % code === 0 ? a + c : a), "" ); console.log(answer); return answer; }; 솔루션 const solution = (cipher, code) => { const answer = []; for (let i = code - 1; i < cipher.length; i += code) { answer.push(cipher[i]); } console.log(answer.join("")); return answer.join(""); }; 솔루션 const sol..
솔루션 const solution = (my_string) => { const str = [...my_string]; console.log(str); const answer = str .map((v) => (v === v.toUpperCase() ? v.toLowerCase() : v.toUpperCase())) .join(""); console.log(answer); return answer; }; 솔루션 const solution = (my_string) => { let answer = ""; for (const str of my_string) { answer += str === str.toLowerCase() ? str.toUpperCase() : str.toLowerCase(); } console..
솔루션 const num = [ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]; const solution = (numbers) => { for (let i = 0; i < num.length; i++) { numbers = numbers.split(num[i]).join(i); } const answer = Number(numbers); console.log(answer); return answer; };