/Hospital-management

Explore a comprehensive solution to streamline and enhance healthcare operations. Our cutting-edge management system seamlessly integrates patient records, appointment scheduling, billing, and inventory management, ensuring efficient and error-free administration. With user-friendly interfaces and robust security features, we empower healthcare .

Primary LanguageJavaScript

MCQ TEST

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

Answer: B: ReferenceError: greetign is not defined

Declared the variable as greeting but then tried to assign an empty object to a variable named greetign. JavaScript is case-sensitive, so greeting and greetign are considered different variables.so say that greetign is not defined

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

Answer: C: "12"

the sum function takes two parameters a and b and attempts to add them together. When you call sum(1, "2"), the first parameter 1 is a number, but the second parameter "2" is a string.In JavaScript, when you use the + operator with a string and a number, the number is coerced into a string, and then the two strings are concatenated.

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

Answer: A: ['🍕', '🍫', '🥑', '🍔']

The info.favoriteFood property is assigned a new value "🍝", but it is not change the food array itself. The array remains unchanged, and its elements are still ["🍕", "🍫", "🥑", "🍔"].

4. Write the correct answer from the following options and give an explanation (2-5 lines).
function sayHi(name) {
  return `Hi there, ${name}`;
}

console.log(sayHi());
  • A: Hi there,
  • B: Hi there, undefined
  • C: Hi there, null
  • D: ReferenceError
Answer

Answer: B: Hi there, undefined

the sayHi function expects a name parameter, but when we call the function in the console.log statement, and do not pass any argument. In JavaScript, if a function parameter is not provided with a value, it will default to undefined.

5. Write the correct answer from the following options and give an explanation (2-5 lines).
let count = 0;
const nums = [0, 1, 2, 3];

nums.forEach((num) => {
  if (num) count += 1;
});

console.log(count);
  • A: 1
  • B: 2
  • C: 3
  • D: 4
Answer

Answer: C: 3

the forEach method iterates over the nums array. Inside the callback function, the code checks if the current num is truthy , and if so, it increments the count variable by 1.

Hospital Management