본문 바로가기

Python_WEB/JavaScript

[freecodecamp]JavaScript + 연산자로 문자열 연결

반응형

JavaScript에서는 + 연산자를 String 값과 함께 사용하는 경우 연결 연산자라고합니다.

다른 문자열을 함께 연결하여 새 문자열을 만들 수 있습니다.

 

예>

'My name is Alan,' + ' I concatenate.'

 

띄어쓰기를 조심하십시오.

연결은 연결된 문자열 사이에 띄어쓰기를 추가하지 않으므로 직접 추가해야합니다.

 

예>

var ourStr = "I come first. " + "I come second.";
// ourStr is "I come first. I come second."

 

Q>

1. "This is the start."및 "This is the end."문자열에서 myStr을 빌드합니다.

2. + 연산자를 사용합니다.

3. myStr의 값은 This is the start입니다.

4. 이 것이 마지막이다.

5. + 연산자를 사용하여 myStr을 빌드해야합니다.

6. myStr은 var 키워드를 사용하여 만들어야합니다.

7. 결과를 myStr 변수에 할당해야합니다.

 

A>

var myStr = "This is the start. " + "This is the end."; // Only change this line

 

https://www.freecodecamp.org/

 

freeCodeCamp.org

Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.

www.freecodecamp.org

 

반응형