×

typescript · level 1 · unit 6 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

Ask an array whether it holds something.

asks an array a yes-or-no question: is this item in you? temps.includes(19) gives true if 19 is there, and false if not.

goes further and tells you where it is. It gives the index of the first match, or -1 when there is no match, because no real index is below 0.

gives the bigger number, 9, and Math.min gives the smaller. Use one in a loop to find the warmest day: keep the best so far, and let each item challenge it.

let temps: number[] = [14, 19, 11, 17];
console.log(temps.includes(19));
console.log(temps.indexOf(11));
console.log(temps.indexOf(30));
console.log(Math.max(4, 9), Math.min(4, 9));

.includes() and .indexOf() look for an exact match, so "Ava" and "ava" are different.