[JavaScript] ๋ฌธ์ œ ํ’€์ด

๋””๋”ฉยท2022๋…„ 11์›” 6์ผ
0

Today I Learned

๋ชฉ๋ก ๋ณด๊ธฐ
6/12
post-thumbnail

๐Ÿ“ 2022. 11. 07

JavaScript / ๋ฌธ์ œ ํ’€์ด



๐Ÿ“Œ Today I Learned

  • concat์„ ํ™œ์šฉํ•œ ์ถœ๋ ฅ ๋ฐฉ๋ฒ•
  • ๋ฌธ์žฅ์„ ๊ฑฐ๊พธ๋กœ ์ถœ๋ ฅํ•˜๊ธฐ

๐Ÿ’ฌ concat์„ ํ™œ์šฉํ•œ ์ถœ๋ ฅ ๋ฐฉ๋ฒ•

๐Ÿ“‡ ๋ฌธ์ œ

๋‹ค์Œ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์™„์„ฑํ•˜์—ฌ ๋‚ ์งœ์™€ ์‹œ๊ฐ„์„ ์ถœ๋ ฅํ•˜์‹œ์˜ค.


// ๋ฐ์ดํ„ฐ
var year = '2019'
var month = '04'
var day = '26'
var hour = '11'
var minute = '34'
var second = '27'

var result = // ๋นˆ์นธ์„ ์ฑ„์šฐ๊ธฐ

console.log(result);

// ์ถœ๋ ฅ
2019/04/26 11:34:27

๐Ÿ’ญ ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ


var year = '2019'
var month = '04'
var day = '26'
var hour = '11'
var minute = '34'
var second = '27'

var result = `${year}/${month}/${day} `
var result2 = `${hour}:${minute}:${second}`
var result3 = result.concat(result2)



console.log(result3)



๐Ÿ’ฌ ๋ฌธ์žฅ์„ ๊ฑฐ๊พธ๋กœ ์ถœ๋ ฅํ•˜๊ธฐ

๐Ÿ“‡ ๋ฌธ์ œ

์ž…๋ ฅ : ๊ฑฐ๊พธ๋กœ
์ถœ๋ ฅ : ๊ฑฐ๊พธ๋กœ

๐Ÿ’ญ ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ

const str = '๊ฑฐ๊พธ๋กœ';

const reversed = str.split('').reverse().join('');

console.log(reversed)

--------

function getReversed(str) {

    const arr = str.split('').reverse().join('');;

    if (typeof str === 'string') {
        return arr
    }
    return 'wrong type'

}

console.log(getReversed('์•ˆ๋…•ํ•˜์„ธ์š”'))
profile
๋ฌด์‚ฌ์™€์š”... ์—ด๊ณตํ–์š”...

0๊ฐœ์˜ ๋Œ“๊ธ€