Compute Hyperbolic Tangent in JavaScript

Posted by yhuang
Public (Editable by Users)
JavaScript
None
Edit
console.log(Math.tanh(-1));
// expected output: -0.7615941559557649

console.log(Math.tanh(0));
// expected output: 0

console.log(Math.tanh(Infinity));
// expected output: 1

console.log(Math.tanh(1));
// expected output: 0.7615941559557649

Math.tanh(0);        // 0
Math.tanh(Infinity); // 1
Math.tanh(1);        // 0.7615941559557649