JavaScript If/else statement and Arrays.

Today, i continued on the Bootcamp Primer, i went through javascript: if/else statement, Loops and arrays. As you can see below, the different exercises:

If/else assignment:

//  var name = "cat"
//  if(name === "dog"){
//      console.log("same")
//  } else if(name !== "dog"){
//      console.log("not the same")
//  }
 //---------------------------------------------
 
//  var person = {
//      name: "Ali",
//      age: 12
//  }
//  if(person.age >= 18){
//      console.log(person.name + " is allowed to go to the movie")
//  } else{
//       console.log(person.name + " is not allowed to go to the movie")
//  }
// -----------------------------------------------
//  if(person.name[0] === "B"){
//       console.log(person.name + " is allowed to go to the movie")
//  }else{
//      console.log(person.name + " is not allowed to go to the movie")
//  }
//  ------------------------------------------------------
//  if(person.name[0] === "B" && person.age >= 18){
//       console.log(person.name + " is allowed to go to the movie")
//  }else{
//      console.log(person.name + " is not allowed to go to the movie")
//  }
//      ----------------------

//  if(1 === "1"){
//      console.log("strict")
//  }else if(1 == "1"){
//      console.log("loose")
//  }else{
//      console.log("not equal at all")
//  }
//  ---------------------- 

// if((1 <= 2 && 1 === 4) == false){
//     console.log("yes")
// }
//  ------------------------

// if("dog"){
//      console.log("is a string")
// }
// if(true){
//      console.log("is a boolean")
// }
//  -------------------------------
//  var a
//  if(a === null){
//      console.log("is null")
//  }
//  ---------------------
//  var myNum = 10
//  if(myNum % 2 === 0){
//      console.log("even")
//  }else{
//      console.log("odd")
//  }

Loops and Arrays Practice:

for(var i = 0; i <= 11; i++){
//    if(i % 2 === 0){
 //       console.log(i + " even ")
//    }else{
//        console.log(i + " odd")
//    }
//}

//--------------------------

// Loops and Arrays Practice
//
//
//var peopleWhoWantToSeeMadMaxFuryRoad = [
//  {
//    name: "Mike",
//    age: 12,
//    gender: "male"
//  },{
//    name: "Madeline",
//    age: 80,
//    gender: "female"
//  },{
//    name: "Cheryl",
 //   age: 22,
//    gender: "female"
//  },{
//    name: "Sam",
//    age: 30,
//    gender: "male"
//  },{
//    name: "Suzy",
//    age: 4,
//    gender: "female"
//  }
//] 
//
//for(var i=0; i < peopleWhoWantToSeeMadMaxFuryRoad.length; i++){
 // if(peopleWhoWantToSeeMadMaxFuryRoad[i].age > 18){
 //     console.log(peopleWhoWantToSeeMadMaxFuryRoad[i].name + " old enough")
 // } else{
 //    console.log(peopleWhoWantToSeeMadMaxFuryRoad[i].name + " not old enough")
 // }
  //  }

//---------------------------------------
//Functions assignement
// // 1. Write a function that returns the sum of any two numbers you give it.
// function myFunction(a,b){
//     return a+b ;
// }
// console.log(myFunction(2,3))

// 2. Write a function that takes a string such has "Joe" as an argument, and returns the string "Hello Joe"
// function myFunction(string){
//     return "Hallo " + string
// }
//  console.log(myFunction("Joe"))
// 3. Write a function that takes in a number as an argument, and returns the string "Even" if the number is even, and "Odd" if the number is odd.

// function myFunction(num){
//     if(num%2 === 0){
//     return "Even "   
//     }else{
//         return "Odd"
//     }
// }
//  console.log(myFunction(33))
//
//Write a function that accepts a string as a parameter. 
//If the length of the string is less than or equal to twenty characters long,
// return the string concatenated with itself (string + string). 
//If the string is more than twenty characters long, return the first half of the string.
//
//function myFunction(string){
//    if(string.length < 20){
//        return string.concat(string);
//    }else {
 //       return string.slice(0, string.length /2);
//    }
//}
//console.log(myFunction("Hallo java tout le monde giusgqo hvlavgl"))

Besides that, i started the intermediate level for typing lessons, without forgetting of course the English lessons on udemy. I plan to continue tomorrow on the bootcamp, and do the proposed exercises and see how it goes.