Created
May 26, 2017 14:33
-
-
Save rflpazini/f8866ebcb142835aa95fbde73f53f07f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calculadora { | |
soma(a, b) { | |
let result = a + b; | |
// Verifica se o resultado da soma convertido em inteiro não é igual ao resultado | |
// se isso for verdade, convertemos o número para float e limitamos o mesmo | |
// para apenas duas casas depois da vírgula | |
if (parseInt(result) != result) { | |
result = parseFloat(result.toFixed(2)); | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment