JavaScript Prework
Pre-work for JavaScript
Remember learning HTML and CSS? To refresh your memory:
- HTML is the markup language that we use to structure and give meaning to our web content, for example defining paragraphs, headings, and data tables, or embedding images and videos in the page.
- CSS is a language of style rules that we use to apply styling to our HTML content, for example setting background colors and fonts, and laying out our content in multiple columns.
The third layer of standard web development is JavaScript.
- JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else. (Okay, not everything, but it is amazing what you can achieve with a few lines of JavaScript code.)
Source: MDN: What is JavaScript?
Pre-work
Work through this W3Schools JavaScript Quickstart Tutorial to familiarize yourself with the basics of JavaScript. Be sure to click the Try it Yourself » button for each example to experiment with the code. You cannot break it; if your code stops working, refresh the browser tab to reset the example.
Answer the following in your notebook. We will revisit them in the lessons ahead.
Questions:
- What are 5 possible data types for JavaScript variables?
- How many numeric data types does JavaScript have?
- What is the name of the JavaScript method that finds an HTML element by its
id
attribute? - True or False: JavaScript can change HTML content, attribute values, and styles (via CSS).
- True or False: JavaScript cannot show or hide HTML elements.
Coding Practice
Write code to complete each of the following tasks:
-
Stores the length of the
schoolName
variable in a new variable calledschoolLength
.var schoolName = 'Turing School of Software and Design';
- Creates an object called
person
that stores yourfirstName
,lastName
,age
, andcity
of residence. - Creates an array called
states
that includes your home state and all bordering states. Feel free to use this map for reference. - A function that takes two arguments and returns the sum.