// Array of friends created to store friends name
const friends = ["Amit", "Sonu", "Monu", "Gonu", "Salu"];
const question = {
prompt: "Which friend is not included in the array?",
options: ["Amit", "Sonu", "Monu", "Gonu", "Saluu"], // Note the extra "u" in "Saluu" to create a wrong answer
correctAnswer: "Saluu"
};
console.log(question);
This code creates an array friends containing the names of your friends. It then defines a question object with a prompt, options, and the correct answer. The prompt asks which friend is not included in the array. The options include the correct answer "Saluu" with an extra "u" to make it incorrect, and the other friends' names as correct options.
Let's go for another aspect of this problem , suppose we have this question .
Question: Which friend is not included in the array ["Amit", "Sonu", "Monu", "Gonu", "Salu"]?
Options:
A. Amit
B. Sonu
C. Monu
D. Gonu
E. Saluu
Correct Answer: E. Saluu
const friends = ["Amit", "Sonu", "Monu", "Gonu", "Salu"];
const question = {
prompt: "Which friend is not included in the array?",
options: ["Amit", "Sonu", "Monu", "Gonu", "Saluu"], // Note the extra "u" in "Saluu" to create a wrong answer
correctAnswer: "Saluu"
};
console.log(question);
This code creates an array friends containing the names of your friends. It then defines a question object with a prompt, options, and the correct answer. The prompt asks which friend is not included in the array. The options include the correct answer "Saluu" with an extra "u" to make it incorrect, and the other friends' names as correct options.
const friends = ["Amit", "Sonu", "Monu", "Gonu", "Salu"];
//Code snippet to access element from array
const question = {
prompt: "Which code will get 'Sonu' from the array?",
options: [
"friends[0]",
"friends.length - 1",
"friends[1]",
"friends['Sonu']"
],
correctAnswer: "friends[1]"
};
console.log(question);
This code creates an array friends containing the names of your friends. It then defines a question object with a prompt, options, and the correct answer. The prompt asks which code will get "Sonu" from the array. The options include the correct answer friends[1], which accesses the second element in the array, and incorrect options that either access the wrong index or use an invalid syntax.
Comments
Post a Comment