DEV Community 👩‍💻👨‍💻

Mark Matthew Vergara
Mark Matthew Vergara

Posted on • Updated on

Javascript Tagalog - Math.trunc

Ano ngaba ang Math.trunc sa Javascript?
Math Function siya na basta aalisin niyalang yung mga decimal places na number. (also i ta-try ni js na i convert ang mga binigay na value as a number if hindi number data-type yung binigay)

console.log( Math.trunc(1.2) ) // 1

console.log( Math.trunc('7.8') ) // 7

console.log( Math.trunc(0.1) ) // 0

console.log( Math.trunc(1.0002) ) // 1

console.log( Math.trunc(-4.004) ) // -4

console.log( Math.ceil('-2.001') ) // 2

Enter fullscreen mode Exit fullscreen mode

NaN kapag nag tinry mo mag pass ng hindi number or any na hindi pwede maconvert as a number

console.log( Math.trunc() ) // NaN
console.log( Math.trunc({}) ) // NaN
Enter fullscreen mode Exit fullscreen mode

More tagalog Javascript Learning Resources:
https://javascript-methods-in-tagalog.vercel.app/

Top comments (0)

Need a better mental model for async/await?

Check out this classic DEV post on the subject.

⭐️🎀 JavaScript Visualized: Promises & Async/Await

async await