#100DaysOfWeb in Python Transcripts
Chapter: Days 25-28: JavaScript Introduction
Lecture: Day 2: 4 JS exercises

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Welcome back to JavaScript Introduction. It's day two now and today it's all about practicing what you have learned so far.
0:10 So now it's time to see into the Demo folder of your checkout. And there you will find a couple of directories and see into the language.
0:20 Now, run JS and debugging are for my lesson but the exercises are in control, flow, functions looping and objects.
0:36 As you see, every exercise has an HTML file that will embed the JavaScript, so you can run it in a browser and you will start with the exercise.html
0:46 and if you're stuck or if you just want to work from the solution, you can use the dash solution files. So let me quickly show them.
0:58 I have a multi-line command showing what's required and some startup code has been provided. So here we make a simple number guessing game
1:08 asking the user for an input partial to an int and check if the number is a secret number. If it's lower, we print to low;
1:15 if it's higher, we print to high. And if we assert a number, we print, you guessed it. Again, if you get stuck you can always look at the solution.
1:28 The second exercise is about using functions. So here, we're going to write a function to some numbers.
1:35 You might have seen this one on the platform, actually it was one of our first bites and here you have the sum the numbers provided to the function
1:42 but if numbers is not defined you sum a default range of 1-100. Now, already you can say that JavaScript is not having built-in range
1:51 so you probably have to write a second function to generate a range from 1-100. But that's awesome, because you should be practicing writing functions.
2:06 Then I got a looping exercise where you're provided with two arrays of names and ages and you write a small program to loop over both.
2:14 For each person, you print a name, the age and if they're allowed to drive, based on their mean age. And it's closely related to what we've seen
2:22 in the previous videos. Now the last exercise is about objects and it's kind of pre-work for the final project but to kind of recounter.
2:39 And here we can just create a list, or array of simple food objects that contain a description and a count of the calories.
2:48 Then you print that to the console. So, some exercises to really get you practicing what you've learnt so far, because as I always say
2:58 the learning's in the practice. And with that done, tomorrow I have some more video lessons lined up, to start looking at the document object model
3:07 a fundamental piece of working with JavaScript. See you tomorrow.


Talk Python's Mastodon Michael Kennedy's Mastodon