Day 9 of 21 Days of Javascript
I have to say, I'm really enjoying using ChatGPT as an additional tutor alongside the key book I'm leaning on for this journey. For example once I got to a section that introduced JS filters, I worked with GPT to produce clear summary notes about filter functions. Here's a copy of what I've saved in my notes:
const words = ["hi", "hello", "JS"];
// If you only write one parameter in your arrow function,
// JavaScript passes only the first one (element) to it.
words.filter((w) => w.length > 2);
// returns ["hello", "JS"]
// If you write two parameters, JavaScript gives you
// the first two (element and index) e.g.
words.filter((w, i) => i % 2 === 0);
// returns ["hi", "JS"] (words at even indexes 0 and 2)
// If you write three, you can also use the entire array e.g.
words.filter((w, i, arr) => w.length === arr[0].length);
// returns ["hi"] (only "hi" has the same length as the first element)
The next step I do in these cases is to ask ChatGPT to create workout exercises to test my understanding of whatever new concept I've learnt. Here's a screenshot from one of these conversations.
