Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

readme.md

JavaScript Practice Task

  1. Print variables

    use the console.log() and alert() JavaScript functions to print the values of the following variable.
  • name: Store your name in this variable
  • age: Store your age in this variable
  1. Creating variables

    use the var, let and const keywords to create 3 different variables. (any variables)

  2. Creating Objects

    create an object that stores the properties of a human being. (e.g. eyeColor, skinColor, hairColor, canWalk)

  3. Creating Arrays

    create an array that stores the list of groceries.

  4. Using multiple data types

    create variables and store the following values:

  • Number
  • String
  • Boolean
  • Object
  • Array
  1. Conditional Statement

    create a variable named isMale and the value is equal to true then print the following message: "User is Male."

  2. Conditional Statement (pt. 2)

    create 2 variables named: age and gender and use conditional statement to output the following messages:

  • If the age is greater than 18 and the gender is male: You can drive a car.
  1. Conditional Statement (pt. 3)

    create a marksheet program using the if-else condition.
  • if the marks are greater than 90, print "Grade: A+" using the console.log() method
  • if the marks are greater than 80 or less than 89, print "Grade: A" using the console.log() method
  • if the marks are greater than 70 or less than 79, print "Grade: B" using the console.log() method
  • if the marks are greater than 60 or less than 69, print "Grade: C" using the console.log() method
  • if the marks are less than 60, print "Grade: F" using the console.log() method
  1. Conditional Statement (pt. 4)

    create a program that asks the user for a number. Create a conditional statement that checks if the number is even or odd.

  2. Loops

    Use for-loop that prints the table of 2 and 3

  3. Loops (pt. 2)

    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 then break the loop.

  4. Use typeof

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 = {};
  1. Objects

    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 the name property of the obj object.
  • Now use the bracket notation [""] to change the age property of the obj object.
  • Now use the dot notation (.) to call the write function of the obj object.
  1. Array

    Create an array that looks like this:
let arr = ["eggs", "bread", "flour", "vegetables", "fruits"];
  • Now use index to change the "bread" value to "onion".
  • Now use index to change the "fruits" value to -0.
  1. Functions

  • Create a function that prints "Hello World!" every time the function is called.
console.log("Hello World!");
  1. Functions (pt. 2)

  • 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);
  1. Functions (pt. 3)

  • 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}`);
  1. Calculator (part-1)

    • 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;
}
  1. Calculator (part-2)

  • 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.
  1. Calculator (part-3)

  • Create a function that will print whatever value is passed to it as a parameter.
function printName(value) {
  console.log(value);
}
  1. Calculator (part-4)

    Put the whole program together.
    1. Call functions with 2 number parameters.
    2. Store the result of the function call in a variable.
    3. Call the print function with name of the variable where you stored the result.