Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
10,287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* 1.1 Hello Worldという文字を出力するメソッドを定義してください | ||
* | ||
*/ | ||
function helloWorld() { | ||
console.log('Hello World'); | ||
} | ||
|
||
/** | ||
* 1.2 const を使って"hoge"という文字列を定義した変数を定義し、それを出力する関数を定義してください | ||
* | ||
*/ | ||
function displayConst() { | ||
const hoge = 'hoge'; | ||
console.log(hoge); | ||
} | ||
|
||
/** | ||
* 1.3 let を使って"hoge"という文字列を定義した変数を定義し、それを出力する関数を定義してください | ||
* | ||
*/ | ||
function displayLet() { | ||
let hoge = 'hoge'; | ||
console.log(hoge); | ||
} | ||
|
||
/** | ||
* 1.4 引数に渡した変数を表示するメソッドを実装してください | ||
* | ||
*/ | ||
function displayArgument(arg) { | ||
console.log(arg); | ||
} | ||
|
||
/** | ||
* 1.5 渡された二つの引数の合計を返却するメソッドを実装してください | ||
* | ||
*/ | ||
function sumTwoArgs(a, b) { | ||
return a + b; | ||
} | ||
|
||
/** | ||
* 1.6 渡された二つの引数の差を返却するメソッドを実装してください | ||
* | ||
*/ | ||
function subtractTwoArgs(a, b) { | ||
return a - b; | ||
} | ||
|
||
/** | ||
* 1.7 渡された二つの引数の商を返却するメソッドを実装してください。0 での割り算はnullを返却してください。 | ||
* | ||
*/ | ||
function quotientTwoArgs(a, b) { | ||
if (b === 0) { | ||
return null; | ||
} | ||
return Math.floor(a / b); | ||
} | ||
|
||
/** | ||
* 1.8 渡された二つの引数の積を返却するメソッドを実装してください | ||
* | ||
*/ | ||
function productTwoArgs(a, b) { | ||
return a * b; | ||
} | ||
|
||
/** | ||
* 1.9 渡された引数の2で割ったあまりを返却するメソッドを実装してください | ||
* | ||
*/ | ||
function remainderTwoArgs(a) { | ||
return a % 2; | ||
} | ||
|
||
/** | ||
* 1.10 渡された引数が2の倍数であることを確認するメソッドを実装してください | ||
* | ||
*/ | ||
function isEven(a) { | ||
return a % 2 === 0; | ||
} | ||
|
||
/** | ||
* 1.11 渡された二つの文字列を連結するメソッドを実装してください | ||
* | ||
*/ | ||
function concatString(a, b) { | ||
return a + b; | ||
} | ||
|
||
module.exports = { | ||
helloWorld, | ||
displayConst, | ||
displayLet, | ||
displayArgument, | ||
sumTwoArgs, | ||
subtractTwoArgs, | ||
quotientTwoArgs, | ||
productTwoArgs, | ||
remainderTwoArgs, | ||
isEven, | ||
concatString | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* 2.1 引数から与えられた値が20以上であれば | ||
* "成年です。" | ||
* それ以外は "未成年です。” | ||
* と出力するメソッドを実装してください | ||
* | ||
*/ | ||
function printMessageByAge(age) { | ||
if (age >= 20) { | ||
console.log('成年です。'); | ||
} else { | ||
console.log('未成年です。'); | ||
} | ||
} | ||
|
||
/** | ||
* 2.2 引数から与えられた時間が | ||
* 4時から12時より前であれば、 Good Morning | ||
* 12時から17時より前であれば、 Hello | ||
* 17時以降であれば、 Good Night | ||
* と出力するメソッドを実装してください | ||
* | ||
*/ | ||
function greeding(hour) { | ||
if (hour >= 4 && hour < 12) { | ||
console.log('Good Morning'); | ||
} else if (hour >= 12 && hour < 17) { | ||
console.log('Hello'); | ||
} else { | ||
console.log('Good Night'); | ||
} | ||
} | ||
|
||
/** | ||
* 2.3 引数から与えられた数字に対応する曜日を | ||
* 0 ・・・Sunday | ||
* 1 ・・・Monday | ||
* 2 ・・・Tuesday | ||
* 3 ・・・Wednesday | ||
* 4 ・・・Thursday | ||
* 5 ・・・Friday | ||
* 6 ・・・Saturday | ||
* と出力するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function getDay(day) { | ||
switch (day) { | ||
case 0: | ||
console.log('Sunday'); | ||
break; | ||
case 1: | ||
console.log('Monday'); | ||
break; | ||
case 2: | ||
console.log('Tuesday'); | ||
break; | ||
case 3: | ||
console.log('Wednesday'); | ||
break; | ||
case 4: | ||
console.log('Thursday'); | ||
break; | ||
case 5: | ||
console.log('Friday'); | ||
break; | ||
case 6: | ||
console.log('Saturday'); | ||
} | ||
} | ||
|
||
module.exports = { | ||
printMessageByAge, | ||
greeding, | ||
getDay | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* 3.1 0~10までを表示するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function printOneToTen() { | ||
for (let i = 0; i <= 10; i++) { | ||
console.log(i); | ||
} | ||
} | ||
|
||
/** | ||
* 3.2 0~10までの数字を数字の大きい順に表示するメソッドを実装してください | ||
* */ | ||
|
||
function printOneToTenDesc() { | ||
for (let i = 10; i >= 0; i--) { | ||
console.log(i); | ||
} | ||
} | ||
|
||
/** | ||
* 3.3 while文を使って0~10までの数字を小さい順番に表示するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function printOneToTenWhile() { | ||
let i = 0; | ||
while (i <= 10) { | ||
console.log(i); | ||
i++; | ||
} | ||
} | ||
|
||
/** | ||
* 3.4 while文を使って0~10までの数字を大きい順番に表示するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function printOneToTenWhileDesc() { | ||
let i = 10; | ||
while (i >= 0) { | ||
console.log(i); | ||
i--; | ||
} | ||
} | ||
|
||
module.exports = { | ||
printOneToTen, | ||
printOneToTenDesc, | ||
printOneToTenWhile, | ||
printOneToTenWhileDesc | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* 4.1 文字列の長さを返却するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function length(str) { | ||
return str.length; | ||
} | ||
|
||
/** | ||
* 4.2 文字列のながさが偶数の場合にtrueを返却するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function lengthIsEven(str) { | ||
return str.length % 2 === 0; | ||
} | ||
|
||
/** | ||
* 4.3 文字列の先頭一文字目を返却するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function firstChar(str) { | ||
return str.slice(0, 1); | ||
} | ||
|
||
/** | ||
* 4.4 文字列の末尾一文字目を返却するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function lastChar(str) { | ||
return str.slice(-1); | ||
} | ||
|
||
/** | ||
* 4.5 文字列と二つの数字a, bを渡すとa文字目から, b文字目まで | ||
* を返却するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function substring(str, a, b) { | ||
return str.slice(a - 1, b); | ||
} | ||
|
||
/** | ||
* 4.6 引数に与えられた二つの引数のうち、一つ目の引数の文字列に二つ目の引数の文字列が | ||
* 含まれることを確認するメソッドを実装してください | ||
* | ||
* example: | ||
* "workplace", "work" => true | ||
* "work", "workplace" => false | ||
* "hogehoge", "" => true | ||
* "hogegeho", "fugafuga" => false | ||
* */ | ||
|
||
function isInclude(a, b) { | ||
return a.includes(b); | ||
} | ||
|
||
/** | ||
* 4.7 引数で渡された文字列を一文字ずつ表示するメソッドを実装してください | ||
* | ||
*/ | ||
|
||
function printByChar(str) { | ||
for (let i = 0; i < str.length; i++) { | ||
console.log(str[i]) | ||
} | ||
} | ||
|
||
|
||
module.exports = { | ||
length, | ||
lengthIsEven, | ||
firstChar, | ||
lastChar, | ||
substring, | ||
isInclude, | ||
printByChar | ||
} |
Oops, something went wrong.