Back to Technology

Javascript Program To Print Numbers From 0 to 50

1 min readBy admin

This is a simple Javascript function to print numbers from 0 to 50. I am going to use an arrow function to print the values.

const print = (number) => {
  for(let i = 0; i <= number; i++) {
     console.log(i); // or
     document.write(i); // you can use this if you want to print in the browser
  }
}

You can call this print method by passing any number as a parameter / argument.

For example:

print(50);

Happy Coding!