Skip to content

Commit e3800b8

Browse files
committed
Merge branch 'master' into solution
2 parents 43b1299 + 989f901 commit e3800b8

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,20 @@ JavaScript Intro to Functions Lab
55

66
1. Practice writing functions
77
2. Explain basics of working with strings
8-
3. Explain the difference between `return` and loggin
8+
3. Explain the difference between `return` and logging
99
4. Practice using `return` and `console.log()`
1010

1111
## Introduction
1212

13-
Welcome to your first JavaScript lab! You'll notice a few new things in this lesson that we haven't encountered before. Don't worry, we'll walk you through them.
13+
Welcome to the JavaScript functions lab! You'll notice a few new things in this lesson that we haven't encountered before. Don't worry, we'll walk you through them.
1414

15-
### Structure
16-
17-
The structure of this lab — where its files and folders are located — looks roughly like the following:
18-
19-
``` shell
20-
├── CONTRIBUTING.md
21-
├── LICENSE.md
22-
├── README.md
23-
├── index.js
24-
├── node_modules/
25-
├── package.json
26-
└── test
27-
└── index-test.js
28-
```
29-
30-
All labs will more or less have the same structure. (And READMEs, for that matter, will still have CONTRIBUTING.md, LICENSE.md, and README.md files.)
31-
32-
`index.js` might be called something else (something more descriptive) in other labs, and so `test/index-test.js` would be renamed accordingly. But `index.js` is also descriptive in its own right, defining something of an entry point for finding one's way around the app. This is often the file where you will write your code. (Later on, we'll introduce `index.html` and `index.css` — you'll have to update or refer to these files sometimes, too!)
15+
Even if you've walked through some of this material before, it's a good idea to review as we code-along — we're writing functions now, after all.
3316

3417
### Code-along
3518

3619
For now, open up `index.js` in your text editor. You should see, well, nothing. We'll fix that soon.
3720

38-
Now upon up `test/index-test.js`. Hey, there's something! What's all of this stuff doing?
21+
Now open up `test/index-test.js`. Hey, there's something! What's all of this stuff doing?
3922

4023
At the very top of the file, you'll see
4124

@@ -141,10 +124,28 @@ Hey! We got one to pass!
141124

142125
Now it's your turn to get the rest of the tests to pass. Note that some of them require you to use `console.log()` instead of `return` — follow the guidance of the tests!
143126

144-
Oh, lastly: just like `.toUpperCase()` changes any string to all uppercase in JavaScript, `.toLowerCase()` (e.g., `'HELLO'.toLowerCase()`) changesany string to all lowercase.
127+
Note that just like `.toUpperCase()` changes any string to all uppercase in JavaScript, `.toLowerCase()` (e.g., `'HELLO'.toLowerCase()`) changesany string to all lowercase.
145128

146-
Good luck! When you're finished, be sure to run `learn submit`!
129+
Additionally, how do we check if a string is all lowercase or all uppercase?
130+
131+
```javascript
132+
var uppercase = "HELLO!"
133+
134+
uppercase.toUpperCase() === uppercase // true
147135

148-
## Resources
136+
var lowercase = 'hello!'
137+
138+
lowercase.toLowerCase() === lowercase // true
139+
140+
var mixedCase = 'Hi there!'
141+
142+
mixedCase.toLowerCase() === mixedCase // false
143+
144+
mixedCase.toUpperCase() === mixedCase // false
145+
```
146+
147+
We can simply check whether the string is the same when we convert it to uppercase or lowercase! If it's the same, then it was already in that case; if not, then it's either in the other case or it's mixed case.
148+
149+
Good luck! When you're finished, be sure to run `learn submit`!
149150

150-
- [npm](https://npmjs.org)
151+
<p class='util--hide'>View <a href='https://learn.co/lessons/javascript-intro-to-functions-lab'>Intro to Functions Lab</a> on Learn.co and start learning to code for free.</p>

test/index-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,18 @@ describe('index', () => {
4343
console.log.restore()
4444
})
4545
})
46+
47+
describe('sayHiToGrandma(string)', () => {
48+
it('returns "I can\'t hear you!" if `string` is lowercase', () => {
49+
expect(sayHiToGrandma('hello')).toEqual("I can't hear you!")
50+
})
51+
52+
it('returns "YES INDEED!" if `string` is uppercase', () => {
53+
expect(sayHiToGrandma('HELLO')).toEqual("YES INDEED!")
54+
})
55+
56+
it('returns "I love you, too." if `string` is "I love you, Grandma."`', () => {
57+
expect(sayHiToGrandma("I love you, Grandma.")).toEqual("I love you, too.")
58+
})
59+
})
4660
})

0 commit comments

Comments
 (0)