DEV Community

Siddharth Kanojiya
Siddharth Kanojiya

Posted on • Edited on

1

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))

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay