ProdanTenev

Numbers N to 1

Mar 18th, 2022
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.34 KB | None | 0 0
  1. // While loop
  2. function numbersNto1(input) {
  3.     let currentNum = Number(input);
  4.     while (currentNum >= 1) {
  5.         console.log(currentNum);
  6.         currentNum--;
  7.     }
  8. }
  9. // For Loop
  10. function numbersNto1(input) {
  11.     let currentNum = Number(input);
  12.     for (let num = currentNum; num >= 1; num--){
  13.         console.log(num);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment