Skip to content

Latest commit

 

History

History
142 lines (106 loc) · 6.54 KB

File metadata and controls

142 lines (106 loc) · 6.54 KB

JS211_CurrentDateTimeProjectCircleCI

Austin Coding Academy

JavaScript 211 Project: Array Practice

Today's Checklist

  1. Fork and Clone
  2. Create a new branch called: yourName-ArrayChallenge
  3. Use a whiteboard to work out a solution to challenges below.
  4. Translate the broad ideas to psuedo code
  5. Convert the psuedo code to real JavaScript Code
  6. Type into your text editor the JavaScript code you've come up with one step at a time
  7. Work through your bugs.
  8. Use node main.js to run the program after every line of code you build.

Challenges

  1. .length - Create an array called cars which consists of 4 different types of cars as String type. The first car type should be Ford and includes Honda.
    • Console.log the length of the array.
    • Use node main.js to run the program.
  2. .concat() - Create another array called moreCars with 4 more different types of cars. The last car type should be Honda.
    • Use the concat method to combine the cars and moreCars arrays into another array called totalCars.
    • Run the program.
  3. .indexOf() and .lastIndexOf() - Use the indexOf method to console.log the index of Honda.
    • Use the lastIndexOf method to console.log the index of Ford.
    • Run the program.
  4. .join() - Use the join method to covert the array totalCars into a string called stringOfCars.
    • Run the program.
  5. .split() - Use the split method to convert stringOfCars back intro an array called totalCars.
    • Run the program.
  6. .reverse() - Use the reverse method to create an array carsInReverse which is the array totalCars in reverse.
    • Run the program.
  7. .sort() - Use the sort method to put the array carsInReverse into alphabetical order.
    • Based on the types of cars you used, predict which item in the array should be at index 0.
    • Use the following code to confirm or reject your prediction: alert(carsInReverse.indexOf('yourPrediction'));
  8. .slice() - Use the slice method to remove Ford and Honda from the carsInReverse array and move them into a new array called removedCars.
  9. .splice() - Use the splice method to remove the 2nd and 3rd items in the array carsInReverse and add Ford and Honda in their place.
  10. .push() - Use the push method to add the types of cars that you removed using the splice method to the carsInReverse array.
  11. .pop() - Use the pop method to remove and console.log the last item in the array carsInReverse.
  12. .shift() - Use the shift method to remove and console.log the first item in the array carsInReverse.
  13. .unshift() - Use the unshift method to add a new type of car to the array carsInReverse.

14 .forEach() - Create an array called numbers with the following items: 23, 45, 0, 2 Write code that will add 2 to each item in the array numbers.

  • .forEach() requires a function to be passed into it as its first argument. Build a function that will add 2 and then use .forEach() to pass each number into your freshly built function. const numbers = [23, 45, 0 , 2, 8, 44, 100, 1, 3, 91, 34]

Hints

  1. Run your unit tests first!!
  2. Use repl.it to write the solution code first. (its a faster environment vs using the node main.js command over and over again.)
  3. Use the your documentation
  4. Push yourself further.
  5. Look at your hints!
  6. Clone, setup, testing, and running instructions for all projects is below

Cloning Your Project

  1. Click the 'Fork' button (choose your account if prompted).

  2. Copy HTTPS URL from your forked repository

  3. In your terminal/gitBash/CommandPrompt navigate (using cd) into a directory where you want to start keeping your repositories. (/jsDevFolder)

  4. Clone your new repository by typing git clone <forked clone URL> (the HTTPS URL you copied above) Forking a repository

  5. Now go into the new directory by using cd project-repo

  6. Add the base repository as an upstream git remote add upstream https://github.com/AustinCodingAcademy/<PROJECT-REPO>.git

  7. Check the configuration of your remotes with git remote -v, it should look very similar to this (except it'll be YOUR username)

$ git remote -v

origin  git@github.com:username/javascript-workbook.git (fetch)
origin  git@github.com:username/javascript-workbook.git (push)
upstream    git@github.com:AustinCodingAcademy/javascript-workbook.git (fetch)
upstream    git@github.com:AustinCodingAcademy/javascript-workbook.git (push)

Setup

  1. From your project directory, run npm i to tell NPM to install all the node modules we use in this class (see package.json)

  2. Use your textEditor (VS Code) to change your files.

  3. When you're finished git status, stage your file git add ., commit your changes git commit -m "functions working", and push to GitHub git push

    git status
    git add .
    git commit -m "Initial Commit"
    git push origin gh-pages
  4. Now go to your forked repository on GitHub (at https://github.com/your-username/javascript-workbook). A little yellow box should have popped up asking you to make a Pull Request. Click to review.

  5. Click "Create Pull Request"

  6. Every time you make a change and push to GitHub, this PR will automatically update. No need to do it more than once.

Get latest workbook updates

  1. To get the latest code/homework/test updates, be sure to have a "clean working directory" by committing or removing all of your changes. You check for a "clean working environment" by running git status and making sure no files show up.

  2. Run git pull upstream gh-pages

Contributing workflow

Running the apps

Simply run node path/to/file.js

example node 01week/rockPaperScissors.js

Running Tests

Tests are a great way to make sure you code works the way you planned it would, and to make sure you don't break something in the future. We will be using them to test our understanding of the lesson. It's also our main way to assign grades for an assignment.

To run a the tests on a file run npm test path/to/file.js, etc.

Running the Linter

Simply run npm run lint

Running the Server

  1. Run npm start
  2. To break out of the server, press ctrl + c