TIL 20221107 - 131번(Math.trunc())

hoin_lee·2022년 11월 7일
0

TIL

목록 보기
95/236

오늘 알고리즘 단계를 넘어갔는데 생각보다 쉬웠던 것 같다.
그 전 단계의 후반부 난이도에 비슷할 거 같았는데 오히려 이번 단계 초반부가 더 쉬운 것 같다.
그리고 전에 java를 들었던 유튜브 채널에서 vue 강의가 올라왔는데 react하면서 같이 들으면 좋을 것 같긴 하다.

오늘 공부

알고리즘 문제 풀기(프로그래머스)
https://github.com/hoinlee-moi/Algorithm

JS기본문법 다시 공부
https://github.com/hoinlee-moi/ModernJS

React 강의 듣기
https://github.com/hoinlee-moi/React_prac

Math.trunc()

소수 자릿수를 제거하여 숫자의 정수 부분을 반환한다.

console.log(Math.trunc(13.37));
// expected output: 13

console.log(Math.trunc(42.84));
// expected output: 42

console.log(Math.trunc(0.123));
// expected output: 0

console.log(Math.trunc(-0.123));
// expected output: -0

다른 세가지 Math 방법과 달리 Math.floor(), Math.ceil() 및 Math.round(), Math.trunc() 작동 방식은 매우 간단하다.
인수가 양수인지 음수인지에 관계없이 점과 그 오른쪽의 숫자를 자른다.

profile
https://mo-i-programmers.tistory.com/

0개의 댓글