DEV Community

Siddharth Kanojiya
Siddharth Kanojiya

Posted on • Edited on

For Loops in JavaScript | JavaScript #7

// Program to add first n Natural number
// let sum = 0
// let n = prompt("Enter the value of n")
// n = Number.parseInt(n)
// for(i = 0; i < n; i++){
// sum += (i+1)
// }
// console.log("Sum of first" + n + " natural number is " + sum)

/*
let obj = {
ragner: 90,
bjorn: 45,
ivar: 57,
sigard:23
}
// For In Loop
for (let a in obj){
console.log("Marks of " + a + " are "+ obj[a] )
}

// For of loop
for (let b of "Ragner") {
console.log(b)
}
*/

Top comments (0)