What will this code output? Spot the bug.
Difficulty: Hard😤
Difficulty: Hard😤
for (var i = 0; i < 5; i++) {
setTimeout(function() {
console.log(i);
}, 1000);
}What is the purpose of the HTML <head> tag?
Anonymous Quiz
39%
To create a header section for the page
9%
To create a footer for the page
14%
To define the main content of the page
39%
To define the document's metadata
What type of language is JavaScript?
Anonymous Quiz
67%
Object-oriented
14%
Procedural
10%
Markup
10%
Assembly
Find the error in the code.
The answer should be: 15
Difficulty: Average😐
The answer should be: 15
Difficulty: Average😐
function sumArray(arr) {
let sum = 0;
arr.forEach(function(num) {
sum =+ num;
});
return sum;
}
let numbers = [1, 2, 3, 4, 5];
console.log(sumArray(numbers));Which CSS property is used to control the transparency of an element?
Anonymous Quiz
38%
transparent
33%
opacity
18%
visibility
11%
transparency
👍3❤1🔥1
What is the purpose of the "else" statement in JavaScript?
Anonymous Quiz
11%
To define a function
9%
To declare a variable
14%
To create a loop
66%
To execute a block of code unconditionally
How can the code be modified to handle both successful and failed promises?
Difficulty: Impossible😈
Difficulty: Impossible😈
const promises = [
Promise.resolve(1),
Promise.reject(new Error('Error'))
];
Promise.all(promises)
.then(results => console.log(results))
.catch(error => console.error(error));
Which CSS property is used to make text bold?
Anonymous Quiz
53%
font-weight
22%
text-weight
22%
bold
2%
font-style
Which HTML tag is used to create a horizontal line?
Anonymous Quiz
11%
<line>
73%
<hr>
11%
<horizontal>
4%
<b>
TEST
Write a calculator in JavaScript with minimal code
Difficulty: Easy🙂
Write a calculator in JavaScript with minimal code
Difficulty: Easy🙂
function calculate(expression) {
try {
let result = eval(expression);
if (isNaN(result)) {
throw new Error("Invalid expression");
}
return result;
} catch (e) {
return "Error: " + e.message;
}
}
let userInput = prompt("Enter an arithmetic expression (for example, 2 + 2):");
if (userInput !== null) {
console.log("Result:", calculate(userInput));
}How can you select all the elements with class "example" in CSS?
Anonymous Quiz
8%
18%
*example
69%
.example
5%
example.example
What is the main difference between the "==" and "===" operators in JavaScript?
Anonymous Quiz
36%
The "===" operator compares values without considering data types, while "==" compares both.
58%
The "==" operator compares values without considering data types, while "===" compares both.
0%
Both operators compare only the value of variables.
6%
Both operators compare only the data type of variables.
Find the error in the code.
The answer should be: 0, 1
Difficulty: Average😐
The answer should be: 0, 1
Difficulty: Average😐
const createCounter = () => {
let count = 0;
return () => {
console.log(count++);
};
};
const counter1 = createCounter();
const counter2 = createCounter();
counter1();
counter2();🤔2
Which property is used to change the text color in CSS?
Anonymous Quiz
15%
text-color
17%
font-color
63%
color
4%
text-style
What does HTML <br> tag represent?
Anonymous Quiz
63%
Line break
7%
Bold text
25%
Break text
5%
Background row
Find the error in the code.
Difficulty: Easy😁
Difficulty: Easy😁
function greet(name) {
console.log("Hello, " + name);
}
greet();