DEV Community

mmvergara
mmvergara

Posted on • Edited on

3 1

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay