Daily Logs/Algorithm Practice
[level 0] 두 수의 연산값 비교하기
Jcob.moon
2025. 5. 19. 15:45
function solution(a, b) {
const ab = Number(String(a) + String(b));
const abab = Number(2 * a * b);
let result;
if (ab >= abab){
result = ab;} else {
result = abab;};
return result;
}
-주요 문법 :
이전 더 크게 합치기와 매우 유사하다.
이번엔 그때는 삼항연산자를 사용했던거와 달리 if...else 문법을 사용해보았다.MDN
function testNum(a) {
let result;
if (a > 0) {
result = "positive";
} else {
result = "NOT positive";
}
return result;
}
console.log(testNum(-5));
// Expected output: "NOT positive"