I am attempting to use JavaScript code to generate a specific pattern.
To do this, I would like the user to input the following parameters:
For instance, the starting number: 2 Insert the final number: 5 Enter the jump: 2
So far I have tried the following method:
let startNumber = Number(prompt("Enter a starting number:"));
let endNumber = Number(prompt("Enter an ending number:"));
let jump = Number(prompt("Enter a jump value:"));
let output = "";
let count = startNumber;
for (let i = 1; i <=endNumber; i++) {
for (let j = 1; j <= i; j++) {
output += count +",";
count++;
}
output += "\n";
}
console.log(output);
>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
Displayed result will be like above example