-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCh 6 JavaScript In Browser Practice Set.js
63 lines (35 loc) · 1.73 KB
/
Ch 6 JavaScript In Browser Practice Set.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Ch 6 JavaScript In Browser Practice Set
// Q1)How can you log a message to the console using the console object?
// console.log("Hello, World!");
// Q2)How can you display an error message in the console using the console object?
// console.error("An error occurred.");
// Q3)How can you clear the console using the console object?
// console.clear();
// Q4)How can you log a warning message to the console using the console object?
// console.warn("This is a warning.");
// Q5)How can you display tabular data as a table in the console using the console object?
// const data = [
// { name: "John", age: 25 },
// { name: "Jane", age: 30 },
// { name: "Bob", age: 35 }
// ];
// console.table(data);
// Q6)How can you write an error message to the console if a condition is false using the console object?
// const value = 10;
// console.assert(value > 20, "Value should be greater than 20.");
// Q7)How can you measure the time taken to execute a block of code using the console object?
// console.time("Timer");
// // Code block to measure execution time
// console.timeEnd("Timer");
// Q8)How can you prompt the user to enter their name and log it to the console using the prompt function?
// const name = prompt("Enter your name:");
// console.log("Hello, " + name + "!");
// Q9)How can you display an alert box with a message to the user using the alert function?
// alert("This is an alert message.");
// Q10)How can you display a confirm dialog box and log the user's choice to the console using the confirm function?
// const result = confirm("Are you sure you want to delete this item?");
// if (result === true) {
// console.log("Item deleted.");
// } else {
// console.log("Deletion cancelled.");
// }