From the course: JavaScript Code Challenges: Creating Web Apps

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Quick overview of the necessary JavaScript concepts

Quick overview of the necessary JavaScript concepts - JavaScript Tutorial

From the course: JavaScript Code Challenges: Creating Web Apps

Quick overview of the necessary JavaScript concepts

- [Instructor] Before we dive into our virtual pet's emotional rollercoaster, let's do a super quick refresher on the JavaScript we'll be using. We'll be using what we already used in the Pomodoro timer module. Most of what we need was actually already covered, so that's good. We're going to be accessing the DOM with getElementById, we're going to be using addEventListener to react to button clicks, we're going to be writing functions to organize our code, and we'll update the UI based on the internal state. These are all things we'll need here as well. There is one new little trick worth pointing out though. We'll use math.min and math.max to make sure our pet's stats, like hunger and happiness, stay within a healthy range. And this will be wrapped in a helper function. And this helper function basically says, hey, now we're going above this and this threshold. So, you can see an example. So, here's a function, clampstat, and we're using the math.max and the math.min to go ahead and…

Contents