Q:

Write a JavaScript program to get the difference between a given number and 13, if the number is greater than 13 return double the absolute difference

0

Write a JavaScript program to get the difference between a given number and 13, if the number is greater than 13 return double the absolute difference.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function difference(n)
 {
    if (n <= 13)
        return 13 - n;
    else
        return (n - 13) * 2;
 }
console.log(difference(32))
console.log(difference(11))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now