8000 add Chapter03 · Vkube/Eloquent-JavaScript@36a5809 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36a5809

Browse files
committed
add Chapter03
1 parent 6a96c9e commit 36a5809

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chapter03(Functions)/Bean_counting.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function countChar(word: string, letter: string): number {
2+
let count = 0;
3+
for (let i = 0; i < word.length; i+ 10000 +) {
4+
if (word.charAt(i) == letter) {
5+
count++;
6+
}
7+
}
8+
return count;
9+
}
10+
function countBs(string) {
11+
return countChar(string, "B");
12+
}
13+
let result = countBs('Bdcd');
14+
console.log(result);

Chapter03(Functions)/bean_counting.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function countChar(word, letter) {
2+
var count = 0;
3+
for (var i = 0; i < word.length; i++) {
4+
if (word.charAt(i) == letter) {
5+
count++;
6+
}
7+
}
8+
return count;
9+
}
10+
function countBs(string) {
11+
return countChar(string, "B");
12+
}
13+
var result = countBs('Bdcd');
14+
console.log(result);

build/Chapter03/bean_counting.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function countChar(word, letter) {
2+
var count = 0;
3+
for (var i = 0; i < word.length; i++) {
4+
if (word.charAt(i) == letter) {
5+
count++;
6+
}
7+
}
8+
return count;
9+
}
10+
function countBs(string) {
11+
return countChar(string, "B");
12+
}
13+
var result = countBs('Bdcd');
14+
console.log(result);

0 commit comments

Comments
 (0)
0