두 문자열을 + 연산자로 합칠 수 있다.
EX)
let firstWord = 'Hello '; let secondWord = 'World'; let word = firstWord + secondWord console.log(word); // Hello World 출력
EX) fullName에 이름을 넣어라.
- fullName의 길이를 console.log로 출력하라.
- 직접 계산하지 계산하지말고, length를 사용하여 길이를 구하라.
Sol )
let fullName = '홍길동'; console.log(fullName.length) // 3 출력
EX)
- length1에는 word1의 길이 값을 할당하고, length2에는 word2의 길이 값을 할당하라.
- 직접 계산하지 말고 length를 사용하여 계산하라.
- console.log에서 두 길이 값의 평균을 구하고 있는 것을 확인하라.
두 숫자를 더해서 2로 나눠 평균을 구하고 있다.
Sol )
let word1 = 'tree' let word2 = 'flower' let length1 = word1.length // length1에 word1의 길이 값 할당 let length2 = word2.length // length2에 word2의 길이 값 할당 console.log( (length1+length2) / 2 ) // 5 출력