Write a function printNumbers(from, to) that outputs a number every second, starting from from and ending with to.

Using setInterval

by SriSri M

JavaScript

function print(from,to) {
	let first = from;
  let stop = setInterval(function() {
  console.log(first);
  if(first == to){
  	clearInterval(stop);
  }
  first++;
},1000);
}

print(0,5);