Let’s dive right in!
Look through these now and then use them to test yourself after doing the assignment:
==
and ===
?You can think of variables as simply “storage containers” for data in your code. Until recently there was only one way to create a variable in JavaScript — the var
statement. But in the newest JavaScript versions we have two more ways — let
and const
.
The above tutorial mentioned this, but it’s important enough to note again: let
and const
are both relatively new ways to declare variables in JavaScript. In many tutorials (and code) across the internet you’re likely to encounter var
statements. Don’t let it bother you! There’s nothing inherently wrong with var
, and in most cases var
and let
behave the same way. But sometimes the behavior of var
is not what you would expect. Just stick to let
(and const
) for now. The precise differences between var
and let
will be explained later.
Numbers are the building blocks of programming logic! In fact, it’s hard to think of any useful programming task that doesn’t involve at least a little basic math… so knowing how numbers work is obviously quite important. Luckily, it’s also fairly straightforward.
You can easily run your own JavaScript code from files you create on your computer. The simplest way to get started is to simply create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta charset="UTF-8"/>
</head>
<body>
<script>
// Your JavaScript goes here!
console.log("Hello, World!")
</script>
</body>
</html>
Save and open this file up in a web browser and then open up the browser’s console by right-clicking on the blank webpage and selecting “Inspect” or “Inspect Element”. In the ‘Developer Tools’ pane find and select the ‘Console’ tab, where you should see the output of our console.log
statement.
console.log()
is the command to print something to the developer console in your browser. Use it for all of the following exercises.
Try the following exercises:
console.log(23 + 97)
into your html file)(4 + 6 + 9) / 77
0.24675
let a = 10
console.log(a)
should print 10
9 * a
let b = 7 * a
(returns undefined) and then console.log(b)
max
with the value 57
actual
to max - 13
percentage
to actual / max
percentage
in the console and press enter you should see a value like 0.7719
This section contains helpful links to other content. It isn’t required, so consider it supplemental for if you need to dive deeper into something.
5-6 months
Job Guarantee
1-on-1 Mentorship