In this project, we'll provide practice JavaScript problems to help you better understand the fundamentals.
Setup
Fork this repository.
Clone your fork.
Open ./practice.js with your code editor.
Open ./index.html with your browser.
Directions
Complete all the activities inside of ./practice.js to make the spec runner pass it's tests. In order to check the progress of the spec runner, open ./SpecRunner.html with your browser. Remember to commit and push your code often. Good luck!
Tips and Tricks
One of the biggest tools at the developer's disposal is the browser's built-in debugger. To use it, open ./index.html with your browser. Another great tool for small and isolated pieces of code is Python Tutor. Just make sure to change the code to JavaScript ES6.
// declare an empty arrayletmyThings=[];// declare an array with itemsletmyThings=['Bike',7,{name: 'Jeff'},['Catfish']]
Objects
// declare an empty objectletcar={}// declare an object with propertiesletcar={make: 'Ford',model: 'GT',year: 2019}// adding or updating properties with dot notationcar.miles=100;// adding or updating properties with bracket notation// if miles already exists on the object, this would change it's value// if it doesn't this will set it as a key with a value of 150car['miles']=150// if a property doesn't exist on an object, it's considered undefinedcar.owner===undefined// true
// Function DeclarationfunctiondoTheThing(){return'Did the thing';}// Function ExpressionletdoTheThing=function(){return'Did the thing';}// Function Parameters, Arguments and Invoking (calling) a Function// name is a function parameter// a variable we'll use in our function bodyfunctionsayMyName(name){// the string 'Your name is Jeff' will be output// from this function because of the return keywordreturn'Your name is '+name;}// function invocation// parentheses after the function tell the function to run// The string Jeff is called an argument (a value passed to a function and received as a parameter)sayMyName('Jeff');// Here we're passing more arguments than there are parameters// Only Jeff will be received as "name" in the parameter listsayMyName('Jeff','Karen')
If you see a problem or a typo, please fork, make the necessary changes, and create a pull request so we can review your changes and merge them into the master repo and branch.
请发表评论