Programming Quiz Channel
رفتن به کانال در Telegram
Programming quizzes and knowledge tests Short quizzes on programming, logic and computer science. Test and improve your coding knowledge. Join 👉 https://rebrand.ly/bigdatachannels DMCA: @disclosure_bds Contact: @mldatascientist
نمایش بیشتر780
مشترکین
-124 ساعت
+37 روز
+1730 روز
آرشیو پست ها
Which of the following is NOT a valid JavaScript variable name?
Which statement is used to execute a function in JavaScript?
Find the error in the code.
Difficulty: Easy😁
function greet(name) {
console.log("Hello, " + name);
}
greet();Find the error in the code.
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();What is the main difference between the "==" and "===" operators in JavaScript?
How can you select all the elements with class "example" in CSS?
TEST
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 the code be modified to handle both successful and failed promises?
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));What is the purpose of the "else" statement in JavaScript?
Which CSS property is used to control the transparency of an element?
Find the error in the code.
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));