Skip to content

Commit a4f041a

Browse files
committed
alert(), promt(), confirm() implementation
1 parent 0f2fcfb commit a4f041a

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Chapter 6/script.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// alert("Hello")
22
console.log("Hey Atul")
33

4+
/*
45
// Console Object Methods
56
console.log("log")
67
console.info("This is an info")
@@ -10,19 +11,30 @@ console.assert("error" != false)
1011
console.assert("error" == false)
1112
1213
console.time("forLoop")
13-
14-
for (let i = 0; i < 500; i++) {
14+
for (let i = 0; i < 10; i++) {
1515
console.log(233)
1616
}
17-
1817
console.timeEnd("forLoop")
1918
2019
console.time("whileLoop")
21-
2220
let i = 0;
23-
while (i < 500) {
21+
while (i < 10) {
2422
console.log(233)
2523
i++;
2624
}
25+
console.timeEnd("whileLoop")
26+
*/
2727

28-
console.timeEnd("whileLoop")
28+
29+
//Interaction: alert, prompt, confirm
30+
alert("Enter the value of a!")
31+
let a = prompt("Enter a here", "578")
32+
a = Number.parseInt(a)
33+
alert("You entered a of type " + (typeof a))
34+
let write = confirm("Do you want to write it to the page")
35+
if (write) {
36+
document.write(a)
37+
}
38+
else {
39+
document.write("Please allow me to write")
40+
}

0 commit comments

Comments
 (0)