Switch it Up!

Lee·2022년 8월 29일

Algorithm

목록 보기
84/92
post-thumbnail

❓ Switch it Up!

Q. When provided with a number between 0-9, return it in words.

Input :: 1

Output :: "One".

If your language supports it, try using a switch statement.

✔ Solution

//#my solution
function switchItUp(number) {
  switch (number) {
      case 0: {
      return "Zero";
    }
    case 1: {
      return "One";
    }
    case 2: {
      return "Two";
    }
    case 3: {
      return "Three";
    }
    case 4: {
      return "Four";
    }
    case 5: {
      return "Five";
    }
    case 6: {
      return "Six";
    }
    case 7: {
      return "Seven";
    }
    case 8: {
      return "Eight";
    }
    case 9: {
      return "Nine";
    }
    default: {
      return null;
    }
  }
}
profile
Lee

0개의 댓글