This course has been updated! We now recommend you take the Getting Started with JavaScript, v2 course.

Check out a free preview of the full Introduction to JavaScript Programming course:
The "Challenge 1" Lesson is part of the full, Introduction to JavaScript Programming course featured in this preview video. Here's what you'd learn in this lesson:

In this challenge, you will write a program to calculate the total price of your phone purchase. You will keep purchasing phones until you run out of money.

Get Unlimited Access Now

Transcript from the "Challenge 1" Lesson

>> Kyle Simpson: I mentioned before our break that there's this practice section at the bottom of chapter one. And essentially it's building on that metaphor that this whole chapter goes through, asking you to write a program to calculate the total price of your phone purchase or whatever. I'm not gonna bore you by repeating this but I will point you specifically to this section of description there ,including also the bonus challenge if you like.

[00:00:24] And what I'm going to do here is suggest that you try that before scrolling down and looking at how I did it. And that may feel a little uncomfortable to you, especially if you're slightly more on the beginner side of this, but just try. There's more value in the attempt than there is in the successful completion of something.

[00:00:43] So just try to take what I've described here and construct a program based upon what you've learned and there are hints in terms of, you wanna use a variable here, you wanna use a function there. And so what I'm gonna do is essentially stop talking for a little bit and I'll probably give about five or ten minutes here for you to work on this practice exercise, available for questions either for those of you online or for those of you here in class.

[00:01:07] I expect that there will be several questions, and if I need to come back and address something to everyone we'll break back in and address it to everyone. But we're gonna actively work on this exercise and I'm gonna encourage you to try it. It's a big enough exercise, not big, it's like 20 lines of code, but it's a big enough exercise but I'm gonna encourage you to write it in a code editor like I've been doing.

[00:01:28] Write something in a code editor like sublime or a text file whatever you wanna do, and then copy and paste that into a console to run it rather than trying to write yourself in the console. Because it's very easy to be on four or five lines of code in your console, it's very easy to get mixed up and accidentally hit enter to early or something so I encourage you to try it in a code editor.

[00:01:50] And so we'll take some time to work on the exercise and if there are questions let me know but definitely read through this sort of description. Your goal is essentially to write a program that simulates parts of purchasing a phone and calculating the price and so forth. So, go for that and let me know if you have questions.