언어 & 기술 스택/HTML & CSS & JS
[JavaScript] 문자열 길이 구하기
github.com/zlrloy
2023. 7. 4. 12:36
자바스크립트로 문자열 길이를 구할 수 있다.
ex.1
const str = "EEE";
console.log(`${str.length}`);
결과값 : 3
ex.2
const word1 = 'green'
const word2 = 'red'
const word3 = 'black'
const length1 = word1.length;
const length2 = word2.length;
const length3 = word3.length;
console.log(length1 + length2 + length3)
결과값 : 13