Advertisement
ErolKZ

Untitled

Sep 19th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1.  
  2. function solve(n) {
  3.  
  4.  
  5. let arr = [1, 'one', 2, 'two', 3, 'three', 4, 'four', 5, 'five', 6, 'six', 7, 'seven', 8, 'eight', 9, 'nine'];
  6.  
  7. let inputNum = String(n);
  8.  
  9.  
  10. for (let i = 0; i < arr.length; i++) {
  11.  
  12. if (Number(inputNum[inputNum.length - 1]) === arr[i]) {
  13.  
  14. console.log(arr[i + 1]);
  15.  
  16. }
  17.  
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement