Core
Interaction

JavaScript Quiz

Wednesday, 4/ 5 – Lab

Instructions

Create a basic HTML document and a main.js JavaScript file. Link to the main.js file in your HTML document. All of your answers should be added to you main.js file.

The questions are ordered by difficulty. If you don’t know a question move on to the next. If you don’t finish all the questions, especially the later questions, that’s OK.

You can use the internet, this website, and any other sources except for your peers to help you answer these questions. No sharing answers.

At the end of the test you must immediately email the files to me at fisherdm@newschool.edu.

You’ll have 20 minutes to complete as much of the quiz as possible.


Questions

  1. For each of the following items, define a variable to hold the value of the item and log it to the console.
    • A string consisting of your name
    • Your favorite number as an integer
    • Your favorite number as a string
    • A boolean value
    • An array consisting of each of the letters of your first name
    • An array consisting of multiple, different data types. Include at least 3 different data types.
    • Add two strings togethers. The first string is your first name, and the second string is your last name.
    • Add two integers togethers to equal the number 100.
  2. For the array you specified in question 1 (consisting of each of the letters of your first name), log the first item of the array and the last item of the array. When you refer to the last item in the array, try to do it by using the length of the array, rather than manually counting the index of the array.

  3. Log the number of characters in the string ‘supercalifragilisticexpialidocious’ by using the length property.

  4. Log the result of this expression: the length of characters in your first name is equal to the length of characters in your last name.

  5. Create a conditional statement that does the following:
    • If all students are here log a message that says all the students are in class
    • Otherwise, log a message that says not everyone is here
  6. Create a for loop that loops through the array of characters in your first name and logs each character.

  7. Create a conditional statement that checks to see if the current time is between 7pm and 9:40pm.

  8. Create a conditional statement with multiple conditions that checks to see what the current date it is, and logs a unique message for each day of the week.

  9. Create 4 arrays consisting of the following items. Define variables to store each of the 4 arrays.
    • Your favorite 3 foods
    • Your favorite 3 animals
    • Your favorite 3 places
    • Your favorite 3 pokemon
  10. Create an array of arrays consisting of the variables from the previous question. Define a variable to hold this array of arrays.

  11. Loop through your array of arrays and log the value of the each item in the array. You should be looping through 4 things, and each value you log should be an array. For example, the first item logged would be an array containing 3 foods, the second item would be an array containing 3 animals, etc.

  12. Create a nested for loop that loops through the array of your favorite items and logs each individual item. The first loop should log the category of the item, while the nested loop should log each individual item in that category.