- 영어로 검색하는 습관!
- 영어 문법은 중요하지 않음
- how to~, what is~, why~
how to add two string data javascript
두 문자열은 + 연산자로 합칠 수 있다
let writer = "팀 켈러,";
let bookTitle = "<팀 켈러, 결혼을 말하다>";
let name = writer + bookTitle;
console.log(name);
console.log(writer + " " + bookTitle);
console.log("팀 켈러," + " " + "<팀 켈러, 결혼을 말하다>");
console.log(2+2) // 4
console.log('2'+'2') // "22"
console.log(22) // 22
console.log(2+'2') // "22"
console.log(2,'2') // 2 "2"
console.log('2','2') // "2" "2"
console.log(2,2) // 2 2
console.log("111"/2) // 55.5
console.log("111"%2) // 1
console.log("111"*2) // 222
console.log("www"/2) // NaN
console.log("www"%2) // NaN
console.log("www"*2) // NaN
string으로 받은 숫자에 사칙연산을 하면 결과값은 숫자이다
선언한 변수명에 '.length'를 붙여서 할당한 value의 길이를 알 수 있다
let fullName1 = 123141; // 123141
let fullName2 = 12314+"123445"; // "12314123445"
let fullName3 = "124"+"a한글123"; // "124a한글123"
console.log(fullName1.length) // undefined
console.log(fullName2.length) // 11
console.log(fullName3.length) // 9
console.log("The length of SEPTEMBER is ", "SEPTEMBER".length);
// "The length of SEPTEMBER is " 5
console.log("The length of SEPTEMBER is "+ "SEPTEMBER".length);
// "The length of SEPTEMBER is 5"
각 변수에 할당된 String 글자수의 평균 구할 수 있다
let book1 = "마음아 넌 누구니";
let book2 = "이동통신과 마이크로파 통신의 실무 이론";
let length1 = book1.length;
let length2 = book2.length;
console.log(length1) // 9
console.log(length2) // 21
console.log((length1+length2)/2) // 15