비교 연산자
> 초과
< 미만
>= 이상
<= 이하
=== 같다
!== 다르다
조건문
if (조건1) {
} else if (조건2) {
} else {
AND 연산자 OR 연산자 NOT 연산자
isStudent && isFemale;
isStudent || isFemale;
!isStudent && isFemale;
기억해야 할 6가지 falsy 값
if (false)
if (null)
if (undefined)
if (0)
if (NaN)
if ('')
Achievement Goals
- truthy와 falsy 가 조건문에서 작동하는 방식을 이해할 수 있다.
- 논리 연산자에 대해 이해할 수 있다.
- if 와 else if , else를 이해하고 무리없이 활용할 수 있다.
- 복잡한 조건문을 활용하여 실생활에서 쉽게 마주할 수 있는 문제를 해결할 알고리즘을 짤 수 있다.
length PROPERTY
let str = 'CodeStates';
console.log (str.length)l
ACCESSING A CHARACTER
let str = 'CodeStates';
console.log(str[0]);
console.log(str[4]);
console.log(str[10]);
CONCATENATING STRINGS
let str1 = 'Code';
let str2 = 'States';
let str3 = '1'
console.log (str1 + str2);
console.log (str3 + 7);
str.indexOf (searchValue)
'Blue Whale'.indexOf ('Blue');
'Blue Whale'.indexOf ('blue');
'Blue Whale'.indexOf ('Whale');
'Blue Whale Whale'.indexOf ('Whale');
'canal'.lastIndexOf ('a');
str.substring (start, end)
let str = 'abcdefghij';
console.log (str.substring (0, 3));
console.log (str.substring (3, 0));
console.log (str.substring (1, 4));
console.log (str.substring (-1, 4));
console.log (str.substring (0, 20));
str.toLowerCase() / str.toUpperCase()
console.log ('ALPHABET'.toLowerCase());
console.log ('alphabet'.toUpperCase());
str.split (separator)
let str = 'Hello from the other side'
console.log (str.split(' '));
Achievement Goals
- 문자열의 속성과 메소드를 이용해 원하는 형태로 만들 수 있다.
- 문자열의 length라는 속성을 활용해 길이를 확인할 수 있다. str.length
- 문자열의 글자 하나하나에 접근할 수 있다. str[1]
- 문자열을 합칠 수 있다. word1 + " " + word2
- 문자열을 원하는 만큼만 잡을 수 있다. str.substring(0, 3)
- 영문을 모두 대문자로 바꿀 수 있다. str.toUpperCase
- 문자열 중 원하는 글자의 index를 찾을 수 있다 str.indexOf('a')
- 문자열 중 원하는 글자가 포함되어 있는지 알 수 있다. str.includes('a')