-
use the
console.log()andalert()JavaScript functions to print the values of the following variable.
name: Store your name in this variableage: Store your age in this variable
-
use the
var,letandconstkeywords to create 3 different variables. (any variables) -
create an object that stores the properties of a human being. (e.g.
eyeColor,skinColor,hairColor,canWalk) -
create an array that stores the list of groceries.
-
create variables and store the following values:
NumberStringBooleanObjectArray
-
create a variable named
isMaleand the value is equal totruethen print the following message: "User is Male." -
create 2 variables named:
ageandgenderand use conditional statement to output the following messages:
- If the age is greater than
18and the gender ismale: You can drive a car.
-
create a marksheet program using the
if-elsecondition.
- if the marks are
greater than 90, print "Grade: A+" using theconsole.log()method - if the marks are
greater than 80 or less than 89, print "Grade: A" using theconsole.log()method - if the marks are
greater than 70 or less than 79, print "Grade: B" using theconsole.log()method - if the marks are
greater than 60 or less than 69, print "Grade: C" using theconsole.log()method - if the marks are
less than 60, print "Grade: F" using theconsole.log()method
-
create a program that asks the user for a number. Create a conditional statement that checks if the number is even or odd.
-
Use for-loop that prints the table of 2 and 3
-
Use while-loop that asks the user for answer of a questions.
What is 2+2?. Keep asking the user until the user gives the correct answer. If the user gives the correct answer thenbreakthe loop.
Use the typeof opertor the determine the data types of the following variables:
let job = "developer";
let age = 20;
let isMale = true;
let list = [];
let animal = {};- Create an object that looks like this:
let obj = {
name: "ARK",
age: "20",
write: function () {
console.log(this.name + " is writing");
},
};- Now use the dot operator
(.)to change thenameproperty of theobjobject. - Now use the bracket notation
[""]to change theageproperty of theobjobject. - Now use the dot notation
(.)to call thewrite functionof theobjobject.
- Create an array that looks like this:
let arr = ["eggs", "bread", "flour", "vegetables", "fruits"];- Now use
indexto change the"bread"value to"onion". - Now use
indexto change the"fruits"value to-0.
- Create a function that prints
"Hello World!"every time the function is called.
console.log("Hello World!");- Create a function that accepts a parameter named:
name. every time the function is called it is passed a name by a user. The function that prints then following message:
console.log("Hello there", name);- Create a function that accepts two parameters named:
name,age. every time the function is called it is passed a name and age by a user. The function then prints the following message:
console.log(`Hello there ${name}, Your age is: ${age}`);-
- Use functions to create a calculator application. The application will have the following functions:
- Addition
function addition(num1, num2) {
return num1 + num2;
}- Subtraction
function subtraction(num1, num2) {
return num1 - num2;
}- Multiplication
function multiplication(num1, num2) {
return num1 * num2;
}- Division
function division(num1, num2) {
return num1 / num2;
}- Now, call each function and pass it 2 parameters (e.g. pass them 2 numbers). Store the results of the function call in different variables.
- Create a function that will print whatever value is passed to it as a parameter.
function printName(value) {
console.log(value);
}-
Put the whole program together.
- Call functions with 2 number parameters.
- Store the result of the function call in a variable.
- Call the print function with name of the variable where you stored the result.