Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(num) {
- let result = "";
- switch (num % 10) {
- case 1:
- result = "one";
- break;
- case 2:
- result = "two";
- break;
- case 3:
- result = "three";
- break;
- case 4:
- result = "four";
- break;
- case 5:
- result = "five";
- break;
- case 6:
- result = "six";
- break;
- case 7:
- result = "seven";
- break;
- case 8:
- result = "eight";
- break;
- case 9:
- result = "nine";
- break;
- case 0:
- result = "zero";
- break;
- }
- console.log(result);
- }
- Решение с масив:
- function solve(num) {
- let result = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
- console.log(result[num % 10]);
- }
- Тарикатско решение:
- function solve(num) {
- console.log(['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'][num % 10]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement