24 lines
538 B
JavaScript
24 lines
538 B
JavaScript
let number1 = Number(prompt("Add meg az intervallum elejét:"))
|
|
let number2 = Number(prompt("Add meg az intervallum végét:"))
|
|
let listaSzamok = []
|
|
|
|
|
|
if (number1 < number2) {
|
|
for (; number1 <= number2; number1++) {
|
|
listaSzamok.push(number1)
|
|
}
|
|
} else {
|
|
for (; number1 >= number2; number1--) {
|
|
listaSzamok.push(number1)
|
|
}
|
|
}
|
|
|
|
console.log(listaSzamok);
|
|
|
|
let sum = listaSzamok.reduce((accumulator, currentValue) => {
|
|
return accumulator + currentValue
|
|
})
|
|
|
|
console.log(sum);
|
|
console.log(listaSzamok.length);
|