ProdanTenev

Numbers From M to N

Mar 18th, 2022
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.36 KB | None | 0 0
  1. // Write a function that receives a number M and a number N (M will always be bigger than N).
  2. // Print all numbers from M to N.
  3.  
  4. // for loop
  5. function numbersMtoN(m, n) {
  6.     for (let num = m; num >= n; num--) {
  7.         console.log(num);
  8.     }
  9. }
  10. // while loop
  11. function numbersMtoN(m, n) {
  12.     while (m >= n) {
  13.         console.log(m);
  14.         m--;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment