Watch this short introductory video on Arrays by Code.org:
Duration: 4 minutes
Watch this recorded Live Session (04/11/2020) about String and Array Methods
Part 1/3 | Duration: 1 hour
Part 2/3 | Duration: 2 hours
Part 3/3 | Duration: 1 hour
Some things to be aware of while going through the tutorial:
var x = cars.length;
var y = cars.sort();
let carsLength = cars.length;
let sortedCars = cars.sort();
The same best practices mentioned above (avoid
var, use meaningful variable names) apply to this tutorial also.
NOTES: If you are unaware of the following command mentioned in this tutorial, here’s a short explanation of what it does:
document.getElementById("demo").innerHTML = fruits;
This command searches through the document (our HTML page), for an element with id demo and replaces its HTML content with the contents of the fruits variable.
For example, let’s say we have the following HTML content in our document:
<div id="target">Some content here</div>
The following code will replace the current HTML content of this div (Some content here) with <strong>JS rocks!</strong>:
let content = "<strong>JS rocks!</strong>";
document.getElementById("target").innerHTML = content;
Computers don’t get tired, and they’re really really fast! For that reason they are well suited to solving problems that involve doing calculations multiple times. In some cases a computer will be able to repeat a task thousands or even millions of times in just a few short seconds where it might take a human many hours. (obviously speed here depends on the complexity of the calculation and the speed of the computer itself). One way to make a computer do a repetitive task is using a loop
Read this MDN article: Looping Code. It’s a long one, but make sure you tackle the ‘Active Learning’ sections at the bottom of the page.
Test Driven Development (TDD) is a phrase you often hear in the dev world. It refers to the practice of writing automated tests that describe how your code should work before you actually write the code. For example, if you want to write a function that adds a couple of numbers, you would first write a test that uses the function and supplies the expected output. Before you write your code the test will fail, and you should be able to know that your code works correctly when the tests pass.
In many ways TDD is much more productive than writing code without tests. If we didn’t have the test for the adding function above, we would have to run the code ourselves over and over, plugging in different numbers until we were sure that it was working… not a big deal for a simple
add(2, 2), but imagine having to do that for more complicated functions, like checking whether or not someone has won a game of tic tac toe: (
game_win(["o", null,"x",null,"x",null,"x", "o", "o"])) If you didn’t do TDD then you might actually have to play multiple games against yourself just to test if the function was working correctly!
We will teach you the art of actually writing these tests later in the course. The following exercises have the tests already written out for you. All you have to do is read the specs and write the code that makes them pass! The very first exercise (
01-helloWorld) is intentionally very simple and walks you through the process of running the tests and making them pass.
Complete the following exercises found in the repository here and submit the Quiz.
LOOKING FOR HELP?
When looking for help, try doing so in the following order:
- Did you try everything you could?
- Did you read the documentation?
- Did you Google for it?
- Did you post your question on Slack/Forum?
- Did you ask your fellow students for help?
- Did you ask your Mentors for help?
- Did you leave a comment on the comments section of this page?
- Did you ask your Instructor for help?
- [27.11.2020] Added codepen to better understand