10000 Improve level1.js and fix bug in level3.js (#12) · muses-code-js/js-intro-workshop@dedc7a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit dedc7a0

Browse files
authored
Improve level1.js and fix bug in level3.js (#12)
* Improve level1.js * Fix incorrect [0] when using document.querySelector * typo
1 parent dff8405 commit dedc7a0

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

js/level1.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,35 @@
44
Comments
55
========
66
7-
Let's start with comments. Comments are notes that people can read and
8-
computers will ignore.
7+
Let's start with comments. This is a comment. Comments are notes that people
8+
can read and computers will ignore.
99
1010
They will help us to guide you through the JavaScript introduction
1111
journey.
1212
*/
1313

14+
// Single line comments look like this.
15+
1416
/*
1517
Multi-line comments look like this.
18+
When you are writing actual code, put it outside these comment blocks,
19+
so the computer doesn't ignore them.
1620
*/
1721

18-
// Single line comments look like this.
19-
20-
2122
/*
2223
Let's start with getting your code on the screen.
2324
2425
There are a few ways you can do it and we will look into a few of them:
2526
26-
* alert('Hello girls!');
27+
alert('Hello girls!');
2728
** This line of code will pop-up a small window in your browser with the text
2829
'Hello girls!' in it, but you need to refresh the opened page first.
2930
30-
* console.log('Hello World!');
31+
console.log('Hello World!');
3132
** This line of code will print 'Hello World!' to the browser's console.
3233
3334
P.S: To see the browser's console you can right click on the window of your
34-
browser(Chrome, Firefox etc) and select 'Inspect' or 'Inspect element'.
35+
browser (Chrome, Firefox etc) and select 'Inspect' or 'Inspect element'.
3536
After that a console will appear on the bottom right side of the page.
3637
*/
3738

@@ -75,9 +76,10 @@
7576
As you can notice, we can give different types of values to our variables -
7677
strings, numbers, booleans etc.
7778
78-
A string is a set of characters, word(s) or phrase(s) that we wrap in quotes,
79-
see 'hello world!' in the previous task.
80-
Numbers - either integers or floats(decimals)
79+
80+
Strings - set of characters, word(s), or phrases that we wrap in quotes, like
81+
'hello world!'
82+
Numbers - either integers or floats(decimals). Not wrapped in quotes
8183
Boolean - it represents logical values - True or False
8284
*/
8385

@@ -123,8 +125,7 @@
123125
alert(sumOfNumbers);
124126
125127
This will pop-up an alert box with the number 4.
126-
127-
(You can see a full list of )
128+
TIP: Note how we didn't put 1 and 3 in quotes, because they are numbers.
128129
*/
129130

130131
// TODO: Create 3 variables:
@@ -143,9 +144,9 @@
143144
Functions
144145
=========
145146
146-
A function is a reusable piece of code, an action that you want to do.
147-
It takes some input (arguments), does some manipulation on it and returns
148-
the output. Use the keyword 'return' to define the return value.
147+
A function is like a blueprint, an action that you want to do.
148+
It takes some input variables called arguments, does some manipulation on
149+
it and returns the output. Use the keyword 'return' to define the return value.
149150
150151
To create a function use the following format:
151152
@@ -303,7 +304,7 @@
303304

304305

305306
///////////////////////////////////////////////////////////////////////////
306-
//Congratulations! You have finished Part 1 of JavaScript Basics! //
307+
// Congratulations! You have finished Part 1 of JavaScript Basics! //
307308
// Stand up, stretch your legs, and celebrate your achievement. //
308-
//The next step will be following the instructions in the level2.js file.//
309+
// The next step will be following the instructions in the level2.js file//
309310
///////////////////////////////////////////////////////////////////////////

js/level3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
262262
Example:
263263
264-
var pageNode = document.querySelector('body')[0];
264+
var pageNode = document.querySelector('body');
265265
var newParagraph = document.createElement('p');
266266
var paragraphText = document.createTextNode('Squee!');
267267
newParagraph.appendChild(paragraphText);

0 commit comments

Comments
 (0)
0