Skip to content

Commit e782b56

Browse files
committed
new challenges, rename entry point file
1 parent 73cceb6 commit e782b56

18 files changed

Lines changed: 127 additions & 21 deletions

File tree

runner.js renamed to index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var jsing = adventure('javascripting');
77
var problems = require('./menu.json');
88

99
problems.forEach(function (prob) {
10-
var p = prob.toLowerCase().replace(' ', '_');
10+
var p = prob.toLowerCase().replace(' ', '-');
1111
var dir = path.join(__dirname, 'problems', p);
1212
jsing.add(prob, function () { return require(dir); });
1313
});

menu.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
"STRING LENGTH",
66
"REVISING STRINGS",
77
"NUMBERS",
8+
"ROUNDING NUMBERS",
89
"NUMBER TO STRING",
910
"FOR LOOP",
1011
"ARRAYS",
1112
"ARRAY FILTERING",
13+
"LOOPING THROUGH ARRAYS",
1214
"OBJECTS",
1315
"OBJECT PROPERTIES",
1416
"OBJECT KEYS",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"author": "sethvincent",
99
"bin": {
10-
"javascripting": "runner.js"
10+
"javascripting": "index.js"
1111
},
1212
"dependencies": {
1313
"adventure": "^2.8.0",

problems/introduction/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ var md = require('cli-md');
44
var run = require('../../run-solution');
55

66
exports.problem = md(
7-
fs.readFileSync(path.join(__dirname, 'problem.md'), 'utf8')
7+
fs.readFileSync(path.join(__dirname, 'problem.md')).toString()
88
);
99

1010
exports.solution = md(
11-
fs.readFileSync(path.join(__dirname, 'solution.md'), 'utf8')
11+
fs.readFileSync(path.join(__dirname, 'solution.md')).toString()
1212
);
1313

1414
exports.verify = function (args, cb) {

problems/introduction/problem.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,5 @@ Check to see if your program is correct by running this command:
2727

2828

2929

30-
> **Need help?**
31-
> View the README for this workshop: github.com/sethvincent/javascripting
30+
> **Need help?** View the README for this workshop: github.com/sethvincent/javascripting
3231

33-
---

problems/introduction/solution.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
# YOU DID IT!
44

5-
In the upcoming challenges we'll describe more in depth what's happening.
5+
Anything between the parentheses of `console.log()` are printed to the terminal.
66

7-
## The most important bit for now:
7+
So this:
88

9-
`console.log()` prints the values that are between the parentheses to the terminal.
9+
```js
10+
console.log('hello');
11+
```
1012

11-
So `console.log("COOOOL")` will print `COOOOL` the terminal.
13+
prints `hello` to the terminal.
1214

13-
We will use this in many of the upcoming challenges.
15+
Currently we are printing a **string** of characters to the terminal: `hello`.
16+
17+
In the next challenge we focus on learning about **strings**.
18+
19+
Run `javascripting` in the console to choose the next challenge.
1420

1521
---

problems/string-length/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ exports.solution = md(
1313

1414
exports.verify = function (args, cb) {
1515
run(args[0], function (err, result) {
16-
if (/hello/.test(result)) cb(true);
16+
console.log(typeof result)
17+
if (result == 14) cb(true);
1718
else cb(false);
1819
});
1920
};

problems/string-length/problem.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
---
22

3-
#
3+
# STRING LENGTH
4+
5+
You will often need to know how many characters are in a string.
6+
7+
For this you will use thing `.length` property. Here's an example:
8+
9+
```js
10+
var example = 'example string';
11+
example.length
12+
```
13+
14+
Make sure there is a period between `example` and `length`.
15+
16+
The above code will return a **number** for the total number of characters in the string.
17+
18+
Create a file named string-length.js.
19+
20+
In that file, create a variable named `example`.
21+
22+
Make the `example` variable reference the string `this is an example`.
23+
24+
Use `console.log` to print the **length** of the string to the terminal.
25+
26+
**Check to see if your program is correct by running this command:**
27+
28+
`javascripting verify strings.js`
429

530
---

problems/string-length/solution.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
22

3-
#
3+
# WIN: 14 CHARACTERS
4+
5+
You got it! The string `this is an example` has 14 characters.
6+
7+
Run `javascripting` in the console to choose the next challenge.
48

59
---

problems/strings/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exports.solution = md(
1313

1414
exports.verify = function (args, cb) {
1515
run(args[0], function (err, result) {
16-
if (/hello/.test(result)) cb(true);
16+
if (/this is a string/.test(result)) cb(true);
1717
else cb(false);
1818
});
1919
};

0 commit comments

Comments
 (0)