๐ŸŒฑ → ๐ŸŒณ

[JavaScript] ๋…ธ๋งˆ๋“œ์ฝ”๋” ๋ฐ”๋‹๋ผJS ์ฑŒ๋ฆฐ์ง€ 3์ผ์ฐจ ๋ณธ๋ฌธ

Client/Javascript

[JavaScript] ๋…ธ๋งˆ๋“œ์ฝ”๋” ๋ฐ”๋‹๋ผJS ์ฑŒ๋ฆฐ์ง€ 3์ผ์ฐจ

BAY 2022. 5. 11. 12:33
728x90

๋ฐ”๋‹๋ผJS๋กœ ํฌ๋กฌ์•ฑ ๋งŒ๋“ค๊ธฐ: From #2.7 to #2.16

 

All Courses – ๋…ธ๋งˆ๋“œ ์ฝ”๋” Nomad Coders

์ดˆ๊ธ‰๋ถ€ํ„ฐ ๊ณ ๊ธ‰๊นŒ์ง€! ๋‹ˆ๊ผฌ์Œค๊ณผ ํ•จ๊ป˜ ํ’€์Šคํƒ์œผ๋กœ ์„ฑ์žฅํ•˜์„ธ์š”!

nomadcoders.co

 

#2.7 Functions

argument : function์„ ์‹คํ–‰ํ•˜๋Š” ๋™์•ˆ ์–ด๋–ค ์ •๋ณด๋ฅผ function์—๊ฒŒ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ• 

 

#2.8 Functions part Two

NaN : Not a Number

ํ•จ์ˆ˜๋ฅผ ๋ถ€๋ฅด๊ณ , ์ž…๋ ฅํ•˜๋Š” ๊ฒƒ ๊นŒ์ง€ ๋ฐฐ์›€

//object ์•ˆ์— function์ด ์žˆ๋Š” ๊ฒฝ์šฐ 

const player = {
    sayHello: function(otherName){
        console.log("Hello " + otherName);
    }
}

player.sayHello("nico");
player.sayHello("lynn");

 

#2.11 Returns

 

#2.13 Conditionals

prompt

: ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด์—ฌ์ฃผ๊ณ  ๊ฐ’์„ ์ž…๋ ฅ ๋ฐ›์Œ

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ์˜ ์‹คํ–‰์„ ๋ฉˆ์ถ”๊ฒŒ ํ•จ(์ž…๋ ฅ ๋ฐ›์„ ๋•Œ๊นŒ์ง€)

CSS๋กœ ๊พธ๋ฐ€ ์ˆ˜ ์—†์–ด์„œ ์ง€๊ธˆ์€ ์ž˜ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ

 

typeof : vaiable์˜ type์„ ํ™•์ธ

 

parseInt : string์„ number๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ํ•จ์ˆ˜

 

#2.14 Conditionals part Two

//age ๋ฐ›์•„์„œ int๋กœ type ๋ณ€๊ฒฝ
const age = parseInt(prompt("How old are you?"));

//age๊ฐ€ Number์•„๋‹ˆ๋ฉด Please write Number ๋ฌธ๊ตฌ ์ถœ๋ ฅ
if(isNaN(age)) {
    console.log("Please write Number");
} else {
    console.log("Thank you for writing your age");
}

 

#2.15 Conditionals part Three

// else if ์‚ฌ์šฉ

const age = parseInt(prompt("How old are you?"));

if(isNaN(age) || age < 0 ) {
    console.log("Please write a real positive Number");
} else if (age < 18){
    console.log("You are too young");
} else if (age >= 18 && age <= 50) {
    console.log("You can drink");
} else {
    console.log("umm,, ");
}

 

728x90