JavaScript Full Course 2023
Note: More questions to be updated in 24 Hours.
Chapter 1 (Data Types)
Assignments
1.1: Create a code to check difference between null and undefined data type. Also check their type using typeof.
1.2: Which type of variables (var, let or const) must be initialized at the time of declaration?
1.3: Guess the Output and Explain Why?
[From video lecture 1.5]
let languages = 'java javaScript python cSharp';
let result = languages.lastIndexOf('S');
console.log(result);
1.4: Guess the Output and Explain Why?
[From video lecture 1.8]
let variable = 'hello programmers';
let result = Number(variable);
console.log(result);
1.5: Guess the Output and Explain Why?
let num1 = 32;
let num2 = '32';
let result1 = num1 !== num2;
let result2 = num1 != num2;
console.log(result1, result2);
1.6: Guess the Output and explain Why?
let str = 'Hello Programmers';
let result = str.includes('r');
console.log(result);
1.7: Guess the Output and Explain Why?
[From video lecture 1.6]
let num1 = 2;
let num2 = 5;
let result = num1 ** num2 * 2;
console.log(result);
1.8: Guess the Output and Explain Why?
let num1 = [1, 2, 4, 5];
let num2 = [6, 5, 8, 0];
let result = num1.concat(num2);
console.log(result);
1.9: Guess the Output and Explain Why?
let a = 5;
let b = 7;
let c = 8;
let result = a < b > c;
console.log(result);
1.10: If your State is split into four equal parts such that in each part there are 1/4 number of people live. You have to find how many people would live in each part? which operators will you use ?
[From video lecture 1.6]
Chapter 2 (Control Flow / Conditional)
Assignments:
2.1: Guess the Output And Explain Why?
let i = 4;
for (let j = 0; i < 10; i++) {
if (j === 1 || i === 6) {
continue;
} else {
console.log(i, j);
if (i === 7) {
break;
}
}
}
2.2: Guess the Output and Explain Why?
let i = 0;
for (i; i < 5; i++) {
console.log(i);
}
2.3: Write a simple Program in which You have to print first 10 numbers in descending order (10...1)?
2.4: Lets say John is looking a new country to live in. He want to live in a country that speaks English, has less than 10 million people. One of the food option between these two must present Spanish food OR English food.
Write an if/else if statement to help john figure out Your country is right for him?
[From video lecture 2.4]
2.5: Guess the Output And Explain Why?
for (let i = 0; i < 10; i++) {
console.log(i);
}
console.log(i);
2.6: use nested-if statement to check your age>18
than check your height height > 5.10.
If both true show any message(I can sit in exam) in the console?
2.7: Create two variables grade and passingYear.Check if your grade == "A" and passingYear < 2020 with the help of ternary operator(Not allowed to use any logical operator).If both condition true print on console Qualify. Otherwise Fail
[From video lecture 2.9]
Chapter 3 (Functions)
Assignments
3.1: Create a function Declaration called describeYourState Which take three parameters Population, traditional food and historical place. Based on this input function should return a String with this format.
My state population is ** Its traditional food is ** and historical place name is ___
3.2: Create a function expression which does the exact same thing as defined in Question 1
3.3: Create function addition which takes two numbers as an argument And return the result of sum of two numbers
Important Note: In the function call you are not passing any parameter. You can modify function to achieve this.
[From video lecture 3.2]
Example;
function addition(num1, num2) {
return num1 + num2;
}
console.log(addition()); //You are not allowed to modify this line any more
3.4: Identify which type of value passed below into the function greet(). What will be the return value of greet ?
let person = {
name: 'john',
age: 25,
};
function greet(person) {
person.name = `Mr ${person.name}`;
return `Welcome ${person.name}`;
}
greet(person);
3.5: Create higher order function named as transformer which take string and firstUpperCaseWord function as an arguments. firstUpperCaseWord is function which make first word UpperCase from a given String.
[From video lecture 3.5]
3.6: create function which will display Your name after every 5 seconds
[From video lecture 3.8]
input
let yourName = "john";
output
"john" after 5 second
"john" after 5 second
"john" after 5 second
"john" after 5 second
.
.
.
and so on.
3.7: Guess the Output And Explain Why?
[From video lecture 3.4]
let arrowFunction = (name = 'Coders') => {
`Welcome ${name}`;
};
console.log(arrowFunction('Programmers'));
3.8: Create a JavaScript Function to find the area of a triangle where lengths of the three of its sides are 5, 6, 7. : Area = Square root of√s(s - a)(s - b)(s - c) where s is half the perimeter, or (a + b + c)/2.
input: area_of_triangle(5, 6, 7);
output: 14.69;
3.9: Create a JavaScript Function to capitalize the first letter of each word of a given string.
input: capitalize('we are the champions');
output: 'We Are The Champions';
Chapter 4 (Objects)
Assignments
4.1: Guess the Output And Explain ?
console.log(Math.round(Math.random() * 10));
4.2: Create an object called country for a country of your choice, containing properties name , capital, language, population and neighbors
- Increase the country population by two million using dot notation.
- Decrease the country population by one million using bracket notation.
- Make
language value in Uppercase.
[From video lecture 4.1]
4.3: Guess the Output and explain Why?
let car = {
color: 'Blue',
model: 2021,
company: 'Toyota',
};
let carColor = 'Blue';
console.log(car[carColor]);
console.log(car.carColor);
4.4: Create a method describeCar inside car object in which you have to print like this in console using template literals