λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
JAVASCRIPT

[JAVASCRIPT] λ¬Έμžμ—΄ λ©”μ„œλ“œ : repeat( )

by _토맀토 2022. 8. 18.
728x90

μžλ°”μŠ€ν¬λ¦½νŠΈ : λ¬Έμžμ—΄ λ©”μ„œλ“œ : repeat()

이번 μ‹œκ°„μ—λŠ” λ¬Έμžμ—΄ λ©”μ„œλ“œμΈ repeat()에 λŒ€ν•΄ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€! 😁


#1. repeat( )

repeat() λ©”μ„œλ“œλŠ” λ¬Έμžμ—΄μ„ 주어진 횟수만큼 λ°˜λ³΅ν•΄ 뢙인 μƒˆλ‘œμš΄ λ¬Έμžμ—΄μ„ λ°˜ν™˜ν•©λ‹ˆλ‹€.

! replace( ) μ‚¬μš© 방법 !
"λ¬Έμžμ—΄".replace("νšŸμˆ˜κ°’");

const str1 = "javascript";

const cirrentStr1 = str1.repeat(0);     // ''
const cirrentStr2 = str1.repeat(1);     // javascript
const cirrentStr3 = str1.repeat(2);     // javascriptjavascript

! point ! λ¬Έμžμ—΄μ˜ 반볡 νšŸμˆ˜κ°’μ€ μ–‘μ˜ μ •μˆ˜μ—¬μ•Ό ν•œλ‹€!

728x90

λŒ“κΈ€


Lucky Charms Rainbow
js
html
css