Secure Your Dream Job!
Elevate your problem-solving skills with our curated sets from top tech companies. Practice for free and prepare for your dream job in tech.
1let n = parseInt(prompt("Enter a number:"));
2let sum = 0;
3for (let i = 1; i <= n; i++) {
4 sum += i;
5}
6console.log("The sum from 1 to", n, "is:", sum);
7
8