Last active
August 29, 2015 14:04
-
-
Save StaniTr/8e2188328eb26c9d8fc1 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
//Функция, която да превръща kw в hp (конски сили) | |
//Вариант 1 | |
function convert_v1(kw_v1){ | |
var hp_v1=Math.round((kw_v1/0.746)*100)/100; | |
return hp_v1; | |
} | |
console.log("Вариант3"); | |
console.log(convert_v1(75)); | |
console.log(convert_v1(150)); | |
console.log(convert_v1(1000)); | |
//Вариант 2 за закръгляне до 2-рия знак на десетичната запетая - връща string | |
function convert_v2(kw_v2){ | |
var hp_v2=(kw_v2/0.746).toFixed(2); | |
return hp_v2; | |
} | |
console.log("Вариант2"); | |
console.log(convert_v2(75)); | |
console.log(convert_v2(150)); | |
console.log(convert_v2(1000)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment