🤖 JavaScript crash course

This is a quick & dirty JS primer to (re-)acquaint people with the basics of JS. I will polish and add more over time.

All code snippets are editable mini-assignments

Working with Numbers

Addition

Use addition to get a result of 20.

3+5

		

Subtraction

Use subtraction to get a result of -10.

10-9

		

Multiplication

Use multiplication to get a result of 100.

3*3

		

Division

Use division to get a result of 3.

100/2

		

Working with Strings

Simple strings

Change the string to read "Hello world!"

"Hi to you"

		

Combining strings (string concatenation)

Replace the blank space with your name.

"My name is " + "______" + "!"

		

Template literals (template strings)

Make some changes.

`
Look ma!

This respects whitespace and newlines.

I can add a JavaScript 'expression' which will evaluate and the
RESULT will be placed in the string if I wrap it with $ and {}
5+5 = ${5+5}

`

		

Variables

Variables allow you to store any value and give it a name.

Var

Change the variable name to answer. Then change the formula. The output should show the correct result.

Note: The last expression in this block result; will show up as the "output". This is mainly needed for this snippet block to work. You usually don't do that in your JS.


var result = 5+5;

result;

		

Functions

Coming later...

let, const, loops