ES - Proper Tail Calls

by Cristi Salcescu

JavaScript

function print(from, to) 
{ 
		const n = from;
    if (n > to)  return;
    
    console.log(n);
    
    //the last statement is recursive call 
    print(n + 1, to); 
}

print(1, 10);