- Fork this repository by clicking "Fork" on this page:
https://github.com/meet-projects/y2s18-intro-js-1
. - In Terminal, change directory onto your Desktop:
cd ~/Desktop
- Clone the repository
y2s18-intro-js-1
onto your Desktop, replacing<username>
with your Github username in the following command:$ git clone https://github.com/<username>/y2s18-intro-js-1
.
- Make sure you are in the
~/Desktop/intro-js-1
directory. Openhello-world/hello-world.html
in Sublime Text (or any other text editor). - In the
<script></script>
tags, useconsole.log
to print "Hello, World" to the console. - Open the Chrome Inspector (
Right Click > Inspect
) in Chromium Web Browser and look for the Console. Check to see if "Hello, World" was output to the console. If not, refresh and try again. - Raise your hand and get checked off by a TA or instructor. Nice work!
- Make sure you are in the
~/Desktop/intro-js-1
directory. Openvars/vars.html
in Sublime Text (or any other text editor). Write all of your code in between the<script></script>
tags. - Use
prompt
to ask the user for the year they were born. Store this value as a Number usingparseInt
in a variable calledbirthYear
. - Ask the user for their lucky number. Store this value as a Number using
parseInt
in a variable calledluckyNumber
. - Create two
String
type variables calledfavFruit
andfavSubject
.favFruit
should contain your favorite fruit, andfavSubject
should contain your favorite subject. - Answer the following questions:
- What is the remainder when
birthYear
is divided byluckyNumber
? - What is the value of
birthYear + luckyNumber
? - What is the value of
birthYear + favSubject
? - What is the value of
favFruit + birthYear + luckyNumber
? - What is the value of
birthYear + luckyNumber + favSubject
?
- What is the remainder when
- Raise your hand and get checked off by a TA or instructor. Nice work!
Not sure what to do? Try Googling for the following terms:
javascript string to int
, javascript variables
, javascript order of operations
- Make sure you are in the
~/Desktop/intro-js-1
directory. Openarrays/arrays.html
in Sublime Text (or any other text editor). Write all of your code in between the<script></script>
tags. - Ask the user for three things that they are excited for about MEET, separated by a comma and a space:
", "
. - Split their answer into an array using and sort the array.
- Finally, join the resulting array together with
", "
and display it on the web page withdocument.write
. - Raise your hand and get checked off by a TA or instructor. Nice work!
Not sure what to do? Try Googling for the following terms:
javascript split string
, javascript sort array
, javascript join array
- Make sure you are in the
~/Desktop/intro-js-1
directory. Openloops/loops.html
in Sublime Text (or any other text editor). Write all of your code in between the<script></script>
tags. - Let's write a guessing game! The code given to you generates a random number from 1 to 100 and stores it in a variable called
randomInt
. Using loops and conditionals, write a guessing game that does the following:- Prompt the user to guess a number.
- If their guess is greater than
randomInt
, tell them that they guessed too high. If their guess is less thanrandomInt
, tell them that they guessed to low. - If they guessed correctly, congratulate them and let them know how many guesses it took them to get the right answer.
- Raise your hand and get checked off by a TA or instructor. Nice work!
- Make sure you are in the
~/Desktop/intro-js-1
directory. Openfunctions/functions.html
in Sublime Text (or any other text editor). Write all of your code in between the<script></script>
tags. - A palindrome is a phrase that, when only letters are kept, reads the same both forwards and backwards. For example, "Madam, I'm Adam" is a palindrome, because when only letters are kept, "madamimadam" is the same as its reverse.
- Write a function called
isPalindrome(<word>)
that returnstrue
orfalse
, depending on whether or not the argument is a palindrome, using our providedisLetter(<char>)
function. Afor
loop and learning to copy an array will be helpful too. - Prompt the user to input a phrase, and then output to the screen a message whether or not their input is a palindrome.
- Raise your hand and get checked off by a TA or instructor. Nice work!
- Try to sort an array of numbers, e.g.
[4, 10, 23, 16]
, using theArray.sort()
method. Why is the answer incorrect? Use Google to find a way to sort numbers correctly in JavaScript.
Write a two player game of Tic-Tac-Toe in JavaScript.
The game should do the following:
- Alternate turns between the two players, prompting each player to enter his or her move as an index from 1 to 9 (for the nine spots on the board).
- When prompting the user for a move, display the current state of the board in the
prompt
. - Check that the player entered a valid move: between 1-9, and only free spaces are allowed.
- After each move, check to see if a player won, or if the game ended in a draw (neither player won).
- After the game ends, ask the players if they want to start a new game, and start a new game if they do.
- JavaScript Numbers: https://www.w3schools.com/jsref/jsref_obj_number.asp
- JavaScript Strings: https://www.w3schools.com/jsref/jsref_obj_string.asp
- JavaScript Errors: https://www.w3schools.com/js/js_errors.asp