0
I’m doing a simple exercise. I need to read a prompt number and print the next 10 on the same line, but the code I created only shows the last one. Someone knows how to solve?
var prompt=require('prompt-sync')()
var numero=Number(prompt('Número: '))
var seguintes= ''
for(var i=1; i<10; i++){
seguintes=numero+i+', '
}
seguinte=numero+i
console.log(`Seguintes: ${seguintes}`)
I appreciate the answers, both solved this doubt, but I had a bigger doubt, because I have a resolution of this exercise that does not use this accumulator "+=". the following code was tested and actually works but inspired me to create the previous code and left me sincerely confused as to whether or not to use the "+=".
var prompt=require('prompt-sync')()
var num=Number(prompt('Número: '))
var resposta = ''
for(var i=num+1; i<=num+10; i++){
resposta = resposta + i + ', '
}
console.log(`Seguintes: ${resposta}`)