React + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
1. Write the correct answer from the following options and give an explanation (2-5 lines).
let greeting;
greetign = {};
console.log(greetign);
- A:
{}
- B:
ReferenceError: greetign is not defined
- C:
undefined
Answer: B
The greetign variable is not defined, as a result it will show ReferenceError when attempting to log it to the console.
2. Write the correct answer from the following options and give an explanation (2-5 lines).
function sum(a, b) {
return a + b;
}
sum(1, "2");
- A:
NaN
- B:
TypeError
- C:
"12"
- D:
3
Answer: C
JavaScript is dynamically typed, and the addition operator (+) is also used for string concatenation. When adding a number (1) and a string ("2"), the string concatenation takes precedence, resulting in the string "12".
3. Write the correct answer from the following options and give an explanation (2-5 lines).
const food = ["🍕", "🍫", "🥑", "🍔"];
const info = { favoriteFood: food[0] };
info.favoriteFood = "🍝";
console.log(food);
- A:
['🍕', '🍫', '🥑', '🍔']
- B:
['🍝', '🍫', '🥑', '🍔']
- C:
['🍝', '🍕', '🍫', '🥑', '🍔']
- D:
ReferenceError
Answer: A
The info.favoriteFood = "🍝" changes the value of the favoriteFood property in the info object, but it doesn't modify the original food array.