You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-25Lines changed: 26 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,37 +5,20 @@ JavaScript Intro to Functions Lab
5
5
6
6
1. Practice writing functions
7
7
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
9
9
4. Practice using `return` and `console.log()`
10
10
11
11
## Introduction
12
12
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.
14
14
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.
33
16
34
17
### Code-along
35
18
36
19
For now, open up `index.js` in your text editor. You should see, well, nothing. We'll fix that soon.
37
20
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?
39
22
40
23
At the very top of the file, you'll see
41
24
@@ -141,10 +124,28 @@ Hey! We got one to pass!
141
124
142
125
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!
143
126
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.
145
128
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
147
135
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`!
149
150
150
-
-[npm](https://npmjs.org)
151
+
<pclass='util--hide'>View <ahref='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>
0 commit comments