Exercises
Exercises
Exercises
1. List and explain with the help of example all JavaScript primitive data types
2. List and explain with the help of example all JavaScript non-primitive data types
3. Discuss all rules to be followed while declaring different JavaScript variables
4. With the help of clear and short source-codes differentiate between JavaScript local
variables from JavaScript global variables
5. In JavaScript, variables can be declared in different way depending on how they are going to
be used. How a JavaScript global variable can be declared within function.
6. Discuss on Internals of global variable in JavaScript
7. With the help of example, discuss to explain about JavaScript Literals
8. Explain the difference between null and undefined in JavaScript
JavaScript Arrays
function removeDuplicates(arr) {
return [...new Set(arr)];
}
const arr=[200,1,30,2,30,2]
console.log(removeDuplicates(arr))
12. In online tests, it is recommended to shuffle questions to prevent cheating in exam, shuffling
questions makes it more challenging for participants to collaborate or cheat during the
exam. If each participant sees questions in a different order, it becomes more difficult for
them to share specific questions or answers in real-time. This contributes to the overall
fairness of the examination process. Consider bellow set of question to be displayed on a
webpage
function shuffleArray(arr) {
return arr.sort(() => Math.random() - 0.5);
}
// Array of participants
const participants = ['Participant1', 'Participant2', 'Participant3', 'Participant4', 'Participant5'];
// Array of questions
const questions = [
'Question1',
'Question2',
'Question3',
'Question4',
'Question5'
];
// Create a map to store the shuffled order of questions for each participant
const shuffledOrders = {};
// Shuffle questions for each participant
participants.forEach(participant => {
const shuffledQuestions = [...questions]; // Create a copy of the original questions array
shuffleArray(shuffledQuestions);
shuffledOrders[participant] = shuffledQuestions;
});
// Display the shuffled orders for each participant
participants.forEach(participant => {
console.log(`${participant}'s Shuffled Order:`, shuffledOrders[participant]);
});
JavaScript Group Discussion
13. Given date of birth from a given API, the data bellow was extracted from a JSON object from
the said API. Make a function to return people born before 2000
JavaScript Objects
To be continued……… [Remember to read and understand all exercises provided in each lecture]