-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathps3.js
More file actions
36 lines (25 loc) · 699 Bytes
/
ps3.js
File metadata and controls
36 lines (25 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let prompt = require("prompt-sync")()
// p1 - print marks object's data in nice way.
const marks = {
carry: 98,
rohan: 70,
soham: 100
}
// Using plan for loop
for (let i = 0; i < Object.keys(marks).length; i++){
console.log(Object.keys(marks)[i]+"'s marks is -", marks[Object.keys(marks)[i]])
}
console.log();
// q2 - print it with for in loop.
// Using for in loop
for (let i in marks){
console.log(i+"'s marks is -" , marks[i]);
}
console.log();
// q3 - program will run until user enters correct number.
const correct_num = 5;
let reply = prompt("Enter value: ");
while (reply != correct_num){
reply = prompt("Try again... ");
}
console.log("Correct answer :)")