[TIL]211109

동호·2021년 11월 9일
0
오늘 목표: 노마드 코더 js 강의 듣기, 졸작으로 만들었던 JSP 프로젝트 실행, to-do list 앱 벤치마킹
결과: 노마드 코더 js 강의 듣기

⏰ 18:30 ~ 20:30
구글에서 찾을수있는 JSP 프로젝트 참고


학원에서 프로젝트에 대한 이야기가 길어져서 집에 오고나니 너무 늦은 시간이 되서
오늘은 노마드 코더 js 강의 듣고 정리하고 마무리!

내일은 졸작으로 만들었던 JSP 프로젝트 실행하고 프로젝트 데이터베이스 구현해서 테스트해보기
to-do list 앱 벤치마킹은 듣고 있는 코틀린 강의가 마무리 될 시점에 시작!


노마드 코더 js 강의

promt는 사용자에게 창을 띄울 수 있게 해주고 2개의 argument를 받는다,

function prompt(message?: string, _default?: string): string

const age = prompt("How old are you?");
console.log(age);

typeof는 value의 type을 확인할 수 있다.

const age = prompt("How old are you?");
console.log(typeof age); // string

숫자형으로 type 변경

function parseInt(string: string, radix?: number): number

console.log(typeof "15", typeof parseInt("15")); // string, number

const age = parseInt(prompt("How old art you?"));
console.log(age, parseInt(age));

숫자가 아닌 값을 입력하면 Nan(Not a Number)


무언가가 Nan인지를 판별하는 방법

function isNaN(number: number): boolean

const age = parseInt(prompt("How old art you?"));
console.log(isNaN(age)); // false

isNan은 boolean을 return한다.

값이 Nan일 때 true, Nan이 아닐 때 false


Conditional(조건문)


if (condition) {
    // condition === true
} else {
    // condition === false
}

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

if (isNaN(age)) {
    console.log("Please writer a number"); // true일 때 실행 
} else {
    console.log("Thank you for writing your age"); // fales일 때 실행 
}

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

if (isNaN(age)) {
    console.log("Please writer a number");
} else if (age < 18){
    console.log("You art too young");
} else {
    console.log("You can drink");
}

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

if (isNaN(age) || age < 0) {
    console.log("Please writer a real positive number");
} else if (age < 18){
    console.log("You art too young");
} else if (age >= 18 && age <= 50) {
    console.log("You can drink");
} else if (age > 50 && age <= 80) {
    console.log("You should exrcise");
} else if (age > 80) {
    console.log("You can do whatever you want");
}

AND : &&는 둘 다 true일 때 true!

OR : ||는 둘 중 하나가 true일 때 true!


profile
안녕하세요!

0개의 댓글