Instructions:
- Add your answers inline to the markdown file.
- Use your own words.
- Come up with an answer from memory. Write it down, even if the answer is "I don't know."
- Then, we will go over the answers in class. Write down your revised answer below your original answer.
-
Draw a diagram of an if statement. Name each of the components and how they work together.
-
Draw a diagram of a for loop. Describe each of its components. Indicate the order in which they are executed / evaluated.
-
Functions
- 3a. Draw a diagram of a function. Describe each of its components and what each component does. Specify which of them are optional.
- 3b. Draw a diagram of a function being called, showing the instruction execution order.
- Primitive Data Types
- 4a. Give an example of an empty string and a non-empty string.
- 4b. Give an example of a boolean.
- 4c. Give an example of a Number.
- Arrays
- 5a. Give an example of an empty array.
- 5b. Give an example of an array with three elements in it.
- 5c. How do you add another element to this array?
- 5d. How do you get the length of this array?
- 5e. Show how to iterate through the array using a loop.
- Objects
- 6e. Give an example of an empty object.
- 6b. Give an example of an object with three keys and three values.
- 6c. Give an example of an object with two keys and two functions as values.
- 6d. Describe one way of adding a key to an object.
- 6e. Describe the other way of adding a key to an object.
- 6f. Explain the difference between these two ways, and when it is appropriate to use each way.
- 6g. Describe how to iterate though an object using a loop.
-
What is an algorithm?
-
For the following problem, first write down how exactly to solve the problem in English. Once you are able to describe it in English, translate it into code.
// Given an array of values, write a function that finds the index of where the value is located, and if nothing is found, returns -1.
// Do not use the indexOf function.
// example: for ['apple', 'orange', 'pineapple']
// 'orange' returns '1'
// 'durian' returns '-1'
- Again, for the following problem, first write down how exactly to solve the problem in English. Once you are able to describe it in English, translate it into code.
// Write a function that finds all the indexes of where the value is located and returns them in an array, and if nothing is found, returns -1
// example: ['apple', 'orange', 'orange', 'pineapple']
// 'orange' returns [1,2]