[React] 금액은 확실하게 알려주자! [ toLocaleString(), Math.trunc()]

비트·2023년 12월 12일

React

목록 보기
9/12
post-thumbnail

💵 금액은 1000보다는 1,000으로

.toLocaleString()

<SpacingStack>
  <Box>
    <Text> {``} </Text>
    <BoldText>{Math.trunc(price).toLocaleString()}</BoldText>
    <Text> {`/ 1 Day `} </Text>
  </Box>
</SpacingStack>

<SpacingStack>
  <Box>
    <Text> {``} </Text>
    <BoldText>{price.toLocaleString()}</BoldText>
    <Text> {`/ 1 Day `} </Text>
  </Box>
</SpacingStack>



💸 소수점 뒤는 내려주자

Math.trunc()

<SpacingStack>
  <Box>
    <Text> {``} </Text>
    <BoldText>{price.toLocaleString()}</BoldText>
    <Text> {`/ 1 Day `} </Text>
  </Box>
</SpacingStack>

<SpacingStack>
  <Box>
    <Text> {``} </Text>
    <BoldText>{Math.trunc(price).toLocaleString()}</BoldText>
    <Text> {`/ 1 Day `} </Text>
  </Box>
</SpacingStack>

🔍 Math.trunc()를 사용한 이유?

[js] Math.trunc() vs Math.floor() (+ '~~' 틸트 연산자)

profile
Drop the Bit!

0개의 댓글