About 2 hours
JavaScript is used on the frontend of almost every website. It’s also a widely-used scripting language that be used on the backend as well. Because of its ubiquity JavaScript is a must know language for any full-stack developer at all b2b or b2c companies. The JavaScript lessons set a solid foundation in JavaScript basics so we can use the language in more robust ways in later lessons.
Which companies use JavaScript variables and operators? Any company with an interactive website: Spotify, YouTube, meetup
Participants will be able to:
JavaScript I - Variables, Strings, Numbers (video walkthrough of slides)
JavaScript I - Variables, Strings, Numbers (slides)
Strings are immutable, which means you can’t get inside them and change the characters. The only way you can change the string that’s associated with a particular variable name is to re-bind that variable name to an entirely new string.
In computer science, we usually begin counting with 0 instead of 1. When you are indexing into a string, JavaScript begins counting at 0. When you are finding the length of a string, JavaScript begins counting at 1.
Instructor demonstrates in the video walkthrough how to work with numbers and strings in JavaScript.
Techtonica staff will assign pairs.
Activity: Basic Calculator
Concepts you’ve seen in this lesson that appear in this activity:
Concepts you’ve seen at Techtonica’s JS workshop that appear in this activity:
Using REPL.it, write a function called calculate
that takes in 3 arguments. You can choose the parameter names for the arguments.
The calculate
function should return the result of the math expression that you’ve specified using the arguments. You’ll need to code the logic so the function knows how to handle all the various math operators.
For example, the function call might look like this: calculate(3, '+', 7)
And in this example, the function should return 10
.
Feel free to use any resource you like if you get stuck, including Codecademy’s JavaScript course.
Swap pairs, read your new pair partner’s code, and do code reviews for each other. Did your second pair partner take a different approach than you did with your first pair partner? If so, how?
Swap pairs once more and repeat.
Here are some other ways you can extend your calculator. Choose whichever one(s) sound most interesting to you!
Form small groups and discuss: