Home >Web Front-end >JS Tutorial >JavaScript fun question: Did you get a bonus?

JavaScript fun question: Did you get a bonus?

黄舟
黄舟Original
2017-02-13 16:09:241099browse

It’s time to distribute project bonuses!

The boss asked you to write a program for him to use. Then after you read the design document, your eyes widened in surprise.

It turns out that this program is to write a function, which receives two parameters, salarysalary, and whether there is a bonusbonus.

Salary is an integer, bonus is a Boolean value.

If bonus is true, then the salary is multiplied by 10!

Otherwise, the salary remains intact.

Returns a salary string starting with the soft girl currency symbol "¥".

Well, after a busy day, it’s not a bad idea to use this topic for leisure and entertainment.

Then get it done quickly!


function bonusTime(salary, bonus) {
    bonus = bonus ? 10 : 1;
    return "¥" + bonus * salary;
}


The above is a fun JavaScript question: Did you get a bonus? Content, for more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn