Friday, February 23, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  71] [ 6]  / answers: 1 / hits: 15649  / 11 Years ago, tue, january 29, 2013, 12:00:00

I want to know whether it is possible?



Let Suppose:



var a = 2592;
var b = 2584;
if(a nearly equal to b) {
// do something
}

More From » javascript

 Answers
23

Like so.



var diff = Math.abs( a - b );

if( diff > 50 ) {
console.log('diff greater than 50');
}


That would compare if the absolute difference is greater than 50 using Math.abs and simple comparison.


[#80555] Monday, January 28, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maxinec

Total Points: 117
Total Questions: 116
Total Answers: 116

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
maxinec questions
;