The question I'm trying to solve is:
- Find the sum of the series (3 + 33 + 333 + 3333 + ... + n), to n terms, where n is an input provided by the user (using prompt).
- Example: Given 5. So the series will become (3 + 33 + 333 + 3333 + 33333). Expected output: 37035
This is my code:
const number = 5;
let sum = 3;
let add;
for (i = 0; i <= number; i++){
add = "";
for (j = 1; j <= i; j++) {
add += 3;
sum = add * 10 + 3
}
sum = sum + *5;
}
console.log(sum);
It's not giving me the desired outcome (which is obviously the issue I'm running into). I haven't used prompt yet because I don't know how to implement it. Could someone please help me?