I am trying to print this pattern using javascript.
but I need to enter by the user the following: for example: enter a starting number: 2 insert a final number: 5 enter the jump :2
so far i try this,
let beginGetal = Number(prompt("Geef een begingetal in:"));
let eindGetal = Number(prompt("Geef een eindgetal in:"));
let sprong = Number(prompt("Geef een sprong in:"));
let string = "";
let count = beginGetal;
for (let i = 1; i <=eindGetal; i++) {
for (let j = 1; j <= i; j++) {
string += count +"," ;
count++;
}
string += "\n";
}
console.log(string);
>2
>3,4,5,
>6,7,8,9,10,
>11,12,13,14,15,16,17,
>18,19,20,21,22,23,24,25,26
like this
Via Active questions tagged javascript - Stack Overflow https://ift.tt/HEF1bm4
Comments
Post a Comment