cyberhorsey / day11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Day 11

Exercises

Timeouts / Intervals

  1. Create a function that takes a single argument, a number, and after a timeout of 5 seconds, logs the number to the console.

  2. Create a function that takes a single argument, a number, on an interval of every 5 seconds, logs the number to the console.

Arrays

  1. Create an array that has strings, numbers, and booleans in it, at least two of each type. Our first mixed-type array. Using array functions (like .filters, .sort, .includes, .map, .forEach, etc), do the following (do NOT use for loops) and log them out to the console: a) Create a new array consisting only of the strings in the array, then sort that array alphabetically ascending (A-Z). b) Create a new array consisting only of the numbers in the array, and then sort them ascending. c) Create a new array consisting only of the numbers in the array, and then sort then descending. d) Create a new array consisting only of the strings in the array, but lowercase all the strings.

  2. Create an array that has 5 objects that follow this user model:

object {
   name: string
   age: number
   isAdmin: boolean
}

Using array functions (like .filters, .sort, .includes, .map, .forEach, etc), do the following and log them out to the console: a) Create a new array consisting only of user's that have an age greater than 20. b) Create a new array consisting only of user's that are admins. c) Create a new array consisting only of user's that are both admin and have an age less than 50. d) Sort the array by the user's names, alphabetically, ascending. e) Sort the array by the user's age, descending (oldest to youngest).

About