Simple multiplication

Lee·2022년 7월 20일
0

Algorithm

목록 보기
53/92
post-thumbnail

❓ Simple multiplication

Q. This kata is about multiplying a given number by eight if it is an even number and by nine otherwise.

✔ Solution

//#my solution
function simpleMultiplication(number) {
    // your code........
  return number % 2 == 0 ? number*8 : number*9;
}




//other solution
function simpleMultiplication(n) {
    return n * (n % 2 ? 9 : 8);
}
profile
Lee

0개의 댓글