DEV Community

Siddharth Kanojiya
Siddharth Kanojiya

Posted on • Updated on

JavaScript Loops and Functions #10

// chapter 3 pratice set
// Q1: Write a program to print the mark of a student in an object using for loop Obj {sage 68, rohan 72,sunny 8}

let marks = {
sage: 68,
rohan: 72,
sunny: 8,
adarsh: 44,
}
for(let i=0;i<Object.keys(marks).length;i++){
// console.log("The marks of " + Object.keys(marks)[i] + "are" + marks[Object.keys(marks)[i]])
}
// Q2 write a program in Q1 using in loop .?

for (let key in marks) {
// console.log("The marks of " + key + " are " + marks[key])
}

// Q3 write a program to print "try again" until the user enter the correct number .

// let cn = 9
// let i
// while (i != cn){
// console.log("Try again")
// i = prompt("Enter a number")
// }
// console.log("You have enterned a correct number")

// write a function to find mean of 5 number

const mean = (a, b, c, d) => {
return (a + b + c + d)/4
}

console.log(mean(4, 5, 6, 7))

Top comments (0)