ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฌธ์ œ

"info_list": [
      {
        "id": 1,
        "name": "์ˆฒ๊ณผ ์ƒํ™œ",
        "category": "๋ฏผ๋ฐ•",
        "address": "์ „๋ผ/์ „์ฃผ์‹œ",
        "min_people": 2,
        "max_people": 3,
        "min_price": 187000,
        "max_price": 264000,
        "image_url": "https://images.stayfolio.com/system/pictures/images/000/058/604/small/632cee6dc35346df1f2c6b5d586ed5e73ec7c8a7.jpg?1606199154"
      },
      ( ... )
      ]

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„œ๋ฒ„์—์„œ ์ˆ™๋ฐ• ๋ฆฌ์ŠคํŠธ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์™€ ํ™”๋ฉด์— ๋žœ๋”๋งํ•˜๊ณ ์ž ํ–ˆ๋‹ค.

 

์ด๋•Œ ํ‚ค ๊ฐ’ ์ค‘ min_price์™€ max_price๋Š” ์›ํ™”๋กœ ํ‘œ์‹œ๋˜์–ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น value๊ฐ’์„ ๊ทธ๋Œ€๋กœ ์“ฐ์ง€ ์•Š๊ณ  ์ •์ œํ•ด์•ผ ํ•˜๋Š” ์ž‘์—…์ด ๋ณ„๋„๋กœ ํ•„์š”ํ•˜์˜€๋‹ค.

 

์ด๋ฅผ ์œ„ํ•ด ์ฒ˜์Œ์—๋Š” ์ˆซ์ž ๊ฐ’์„ toString()์„ ํ†ตํ•ด ๋ฌธ์ž์—ด๋กœ ๋ฐ”๊ฟ”์ค€ ๋’ค์— String.prototpye.split ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ ๋ฌธ์ž๋“ค์„ ๋ฐฐ์—ด ๋‚ด์— ์ ์žฌํ•ด์ฃผ๋Š” ์ž‘์—…์„ ํ•˜์˜€๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ •ํ•ด์ง„ ์œ„์น˜์— ์‰ผํ‘œ๋ฅผ ์ฐ๊ธฐ ์œ„ํ•ด ์ธ๋ฑ์Šค๋ฅผ ์กฐํšŒํ•˜๋Š” ์ž‘์—…์„ ๋์œผ๋กœ ์›ํ™”๋กœ ๋ฐ”๊พธ๋Š”๋ฐ์— ์„ฑ๊ณตํ•˜์˜€๋‹ค.

 

ํ•˜์ง€๋งŒ ์›ํ™”๋กœ ๋ฐ”๊ฟ”์ฃผ๊ธฐ ์œ„ํ•œ ํ•ด๋‹น ์—ฐ์‚ฐ ๊ณผ์ •์ด ๋ถˆํ•„์š”ํ•œ ์ฝ”๋“œ๋ฅผ ๋Š˜๋ฆฌ๊ฒŒ ๋˜์—ˆ๊ณ , ๊ฒฐ๊ณผ์ ์œผ๋กœ ํ™”๋ฉด์— ๋žœ๋”๋ง๋˜๋Š” ๋ชฉ์ ์œผ๋กœ๋งŒ ์“ฐ์ผ InfoFeed ์ปดํฌ๋„ŒํŠธ์˜ ๋ชฉ์ ์ด ๋‹ค์†Œ ํ‡˜์ƒ‰๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค.

 

์ด์— ์ข€ ๋” ์ข‹์€ ๋ฐฉ์•ˆ์„ ์ฐพ๊ณ ์ž ํ–ˆ๋‹ค.

 

Refactor_Array.prototype.toLocaleString

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

 

Number.prototype.toLocaleString() - JavaScript | MDN

The toLocaleString() method returns a string with a language-sensitive representation of this number.

developer.mozilla.org

The toLocaleString() method returns a string with a language-sensitive representation of this number.

toLocaleString ๋‚ด์žฅ ๋ฉ”์„œ๋“œ๋Š” ์ธ์ž๊ฐ’์— ํ• ๋‹นํ•œ ์–ธ์–ด ํ‘œํ˜„์— ๋”ฐ๋ผ ์ˆซ์ž๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ฐ”๊ฟ”์ฃผ๋Š” ๋ฉ”์„œ๋“œ์ด๋‹ค.

 

ํ˜„์žฌ ๋ณธ์ธ ํ”„๋กœ์ ํŠธ์—์„œ ์“ฐ์ด๋Š” ๊ธˆ์•ก ํ‘œํ˜„ ๋ฐฉ์‹์€ ์›ํ™”์ด๊ธฐ ๋•Œ๋ฌธ์— 'ko-kr'์„ ์‚ฌ์šฉํ•˜์—ฌ ์•„๋ž˜์™€ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์˜€๋‹ค.

              <br />
              ๊ธฐ์ค€ {info.min_people}๋ช… (์ตœ๋Œ€ {info.max_people})
              <br />
              {`โ‚ฉ${Math.floor(info.min_price).toLocaleString(
                'ko-KR' 
              )} ~ โ‚ฉ${Math.floor(info.max_price).toLocaleString('ko-KR')}`}
            </InfoAddressContainer>
            
            ( ... )

 

๊ฒฐ๊ณผํ™”๋ฉด

 

๋Œ“๊ธ€
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
TAG
more
ยซ   2025/01   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
๊ธ€ ๋ณด๊ด€ํ•จ