Skip to content

Commit a23fc54

Browse files
committed
Add comments
1 parent 039ed54 commit a23fc54

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

README.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#Javascript Function Exercises
22

3-
navigate to this project in your terminal
4-
run `http-server`
5-
open [http://localhost:8000](http://localhost:8000) in chrome
6-
*you should see failing tests*
3+
1. Navigate to this project in your terminal
4+
2. Run `http-server`
5+
3. Open [http://localhost:8000](http://localhost:8000) in Chrome
76

8-
Create 20 functions by following the comments in `functions.js`.
9-
*write all of functions below in `functions.js`*
7+
*You should see failing tests.*
108

11-
after you write each function:
12-
- save `functions.js`
13-
- reload [http://localhost:8000](http://localhost:8000) in chrome
14-
- check if your test passes.
15-
- if it passes, [commit your work](http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository)
9+
Create 20 functions by following the comments in `functions.js`.
10+
*Write all of functions below in `functions.js`*
11+
12+
After you write each function:
13+
1. Save `functions.js`.
14+
2. Reload [http://localhost:8000](http://localhost:8000) in Chrome.
15+
3. Check if your test passes.
16+
4. If it passes, [commit your work](http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository).
1617

1718
---
1819

@@ -94,7 +95,7 @@ Divides the first number by the second.
9495

9596
**Returns**: number, the quotient
9697

97-
square(x,)
98+
square(x)
9899
-----------------------------
99100
Multiplies a number by itself.
100101

@@ -254,3 +255,5 @@ Use [Math.PI](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
254255
-----------------------------
255256

256257
![js-functions](http://i.imgur.com/HmYgp37.jpg)
258+
259+
After all your tests pass, practice calling functions by following the comments in `script.js`.

script.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Follow the comments below.
3+
* Feel free to use `console.log` to see what values are being returned.
4+
5+
// Create a variable called `myNumber`, and assign it to any number
6+
7+
/**
8+
* Create another variable called `stringValue`.
9+
* Assign it the value that's returned when you pass
10+
* `myNumber into the function `numberToString`.
11+
*/
12+
13+
/**
14+
* If you pass `myNumber` and `stringValue` into `areEqual`,
15+
* what value will you get back? Why is that?
16+
*/
17+
18+
/**
19+
* You may have noticed that the `calculate` function combined
20+
* the functionality of `add`, `subtract`, `multiply`, and `divide`.
21+
* Did you try to use those functions _inside_ of `calculate`?
22+
* If you didn't go back and try it, this is called "reusability"!
23+
*/
24+
25+
// Do you see any other functions where code could be reused?
26+
27+
/**
28+
* For your `letterGrade` function,
29+
* what happens if you provide a `score` that is less than 0,
30+
* or greater than the `total` value?
31+
* Does it still work as expected? If it doesn't, how could you improve this?
32+
*/
33+
34+
/**
35+
* Your `combine` function looks okay,
36+
* but what if you wanted to join it with ANY string instead of a single space?
37+
* Create a new function called `improvedCombine`,
38+
* with the same parameters as `combine`, but also add a
39+
* third parameter called `glue` (a string value).
40+
*/
41+
42+
// What happens if you were to uncomment the following lines?
43+
44+
// combine = improvedCombine;
45+
// console.log(combine('combine', 'improved!', ' is '));

0 commit comments

Comments
 (0)