Functions , Conditionals, Loops

  • Make sure to git add .
  • git commit -m " with a message "
  • git push

After each πŸ‘‰ make a add,commit,push

Task-1

Inside Main.js do the following code from below

(make sure to call the functions)

FUNCTIONS


Add Two Numbers:

πŸ‘‰ 1a. Make a function that takes in two parameters and returns the sum of them both


Minus Two Numbers:

πŸ‘‰ 1b. Make a function that takes in two parameters and returns one number minus another.


Multiple Two Numbers:

πŸ‘‰ 1c. Make a function that takes in two parameters and return the multiplication of them both


Divide Two Numbers:

πŸ‘‰ 1d. Make a function that takes in two parameters and return the division of them both


Task-2

CONDTIONALS


πŸ‘‰ 2a. Make an if statement that logs helloword to the browser

πŸ‘‰ 2b. Create a function that takes in a number and checks if a number is higher then 5 ,if the number is heigher then 5 log the string im heigher then 5, else log the string lower then 5


πŸ‘‰ 2c.

  • Create a function that takes in a number.
  • Create a variable inside of the function, call it number and set it to the number 10.
  • inside the function check if the number passed in from the function is heigher then 5, if it is add 5 to the variable called number and console.log it
  • else console.log the string not added

Task-3

Arrays

πŸ‘‰ 3a.

  • Create a variable called savedNumberArray and set it to an empty Array
  • Create a function called addNumberToArray that passes in a number
  • Add the number to the Array
  • Call the function
  • Change the number and console.log the array to see if the number has been added

Task-4

LOOPS

πŸ‘‰ 4a. Make a for loop that loops to the number 10 and logs the string i can count to this number


πŸ‘‰ 4b. Create a functions called looping and put task3-3a ^ above code inside of it and call it.

πŸ‘‰ 4c.

  • Create a function called AddingOnLoops
  • Create a vairable called myNumbers and set it to 0
  • Create a for loop inside of the function that loops to 5
  • inside the for loops add 3 to the variable myNumbers
  • console.log myNumbers after the for loop

your result should be 15 in the console
πŸ’₯BONUS TASK-1:
  • Declare a variable called MyArray set it to an empty Array.
  • Below the array create a function called addToArray
  • inside the function add a for loop that loops to 10 and adds the number 5 to the above MyArray Vairable on each itteration

πŸ’₯BONUS TASK-2:

  • Declare a variable called MyArray set it to an empty Array.
  • Below the array create a function called addToArray
  • inside the function add a for loop that loops to 10 and adds the number 5 to the above MyArray Vairable on each itteration

Basic_Function_Conditions_Loops