10.02.2018 Views

js_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Javascript<br />

Return Value<br />

Returns the value of a number rounded to the nearest integer.<br />

Example<br />

Try the following example program.<br />

<br />

<br />

JavaScript Math round() Method<br />

<br />

<br />

<br />

var value = Math.round( 0.5 );<br />

document.write("First Test Value : " + value );<br />

var value = Math.round( 20.7 );<br />

document.write("Second Test Value : " + value );<br />

var value = Math.round( 20.3 );<br />

document.write("Third Test Value : " + value );<br />

var value = Math.round( -20.3 );<br />

document.write("Fourth Test Value : " + value );<br />

<br />

<br />

<br />

Output<br />

First Test Value : 1<br />

Second Test Value : 21<br />

Third Test Value : 20<br />

Fourth Test Value : -20<br />

302

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!