Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7b16a00

Browse files
fiveth commit
1 parent 96ab9e6 commit 7b16a00

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎beginner/ex11.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Have the function simpleAdding(num) add up all the numbers from 1 to num. For
3+
* example: if the input is 4 then your program should return 10 because 1 + 2 +
4+
* 3 + 4 = 10. For the test cases, the parameter num will be any number from 1
5+
* to 1000.
6+
*/
7+
8+
function simpleAdding(num) {
9+
let sum = 0;
10+
for(i =1; i <= num; i++) {
11+
sum +=i;
12+
}
13+
return sum;
14+
}
15+
16+
console.log(simpleAdding(4));

‎beginner/ex12.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Have the function letterCapitalize(str) take the str parameter being passed
3+
* and capitalize the first letter of each word. Words will be separated by only
4+
* one space.
5+
**/
6+
7+
function letterCapitalize(str) {
8+
let newString = '';
9+
for(let i = 0, newWord = true; i < str.length; i++) {
10+
if (newWord) {
11+
newString += str[i].toUpperCase();
12+
} else {
13+
newString += str[i];
14+
}
15+
newWord = str[i] === ' ' ? true : false;
16+
}
17+
return newString;
18+
}
19+
20+
console.log(letterCapitalize("hazal yilmaz"));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /