Skip to content

Instantly share code, notes, and snippets.

@saraho1123
Last active June 1, 2020 00:00
Show Gist options
  • Save saraho1123/255dd980692af9d0c791bea18a8fb5d1 to your computer and use it in GitHub Desktop.
Save saraho1123/255dd980692af9d0c791bea18a8fb5d1 to your computer and use it in GitHub Desktop.

Day 2 Questions

  1. Create an array containing the following strings: "zebra", "giraffe", "elephant".

    • ["Zebra", "Giraffe", "Elephant"];
  2. Save the array you created above to a variable animals.

    • var animals = ["Zebra", "Giraffe", "Elephant"];
  3. using the array animals, how would you access "giraffe"?

    • console.log(animals[1]);
  4. How would you add "lion" to the animals array?

    • animals.push("Lion");
  5. Name and describe two additional array methods.

    • pop will remove an item from an array variable.

      • To remove "elephant":

      animals.pop();

    • unshift will add items to the front of the array variable.

      • To add "gorilla" and "crocodile":

      console.log(animals.unshift("gorilla", "crocodile"));

  6. What are the boolean values in JavaScript?

    • booleans are true/false. They are helpful when code can take more than one path (I don't fully understand this yet, but I think I am grasping the general idea of it.)
  7. In JavaScript, how would you evaluate if 2 is equal to 25? What is the result of this evaluation?

    console.log(2 == 25);

    false

  8. In JavaScript, how would you evaluate if 25 is greater than 2? What is the result of this evaluation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment