-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
32 additions
and
29 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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
"use strict"; | ||
function getFirstElement(arr) { | ||
return arr[0]; | ||
function sampleFunction3() { | ||
const x = 1; | ||
if (x == 1) { | ||
const y = 2; | ||
console.log(y); | ||
console.log(`if文内${globalVariable}`); | ||
} | ||
for (let i = 0; i < 1; i++) { | ||
const z = 3; | ||
console.log(`for文内:${globalVariable}`); | ||
} | ||
console.log(`関数内:${globalVariable}`); | ||
} | ||
//number型の配列 | ||
const numbers = [1, 2, 3, 4, 5]; | ||
const firstNumber = getFirstElement(numbers); | ||
console.log(firstNumber); | ||
// string型の配列 | ||
const strings = ["りんご", "みかん", "バナナ"]; | ||
const firstString = getFirstElement(strings); | ||
console.log(firstString); | ||
const globalVariable = 10; | ||
console.log(`グローバルスコープ:${globalVariable}`); | ||
sampleFunction3(); |
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 |
---|---|---|
@@ -1,22 +1,20 @@ | ||
if (true){ | ||
let sum:number=0; | ||
sum=3+5; | ||
console.log(sum); | ||
} | ||
console.log(sum); | ||
function sampleFunction3():void{ | ||
const x=1; | ||
|
||
for(let i=0;i<10;i++){ | ||
let sum:number=0; | ||
sum=i+10; | ||
console.log(`S{i}:${sum}`); | ||
} | ||
console.log(sum); | ||
console.log(i); | ||
if(x==1){ | ||
const y=2; | ||
console.log(y); | ||
console.log(`if文内${globalVariable}`); | ||
} | ||
|
||
function sampleFunction():void{ | ||
const x=1; | ||
console.log(x); | ||
for(let i=0;i<1;i++){ | ||
const z=3; | ||
console.log(`for文内:${globalVariable}`); | ||
} | ||
console.log(`関数内:${globalVariable}`) | ||
} | ||
sampleFunction(); | ||
console.log(x); | ||
defined | ||
|
||
const globalVariable:number=10; | ||
console.log(`グローバルスコープ:${globalVariable}`); | ||
|
||
sampleFunction3(); |