K
K
kirillleogky2019-12-18 20:55:39
JavaScript
kirillleogky, 2019-12-18 20:55:39

How to solve no-mixed-operators error?

There is a task:
Returns the angle (in radians) between the hands of an analog clock for the specified Greenwich time.
Examples:
* angleBetweenClockHands(Date.UTC(2016, 3, 5, 0, 0)) => 0
* angleBetweenClockHands(Date.UTC(2016, 3, 5, 3, 0)) => Math.PI/2
* angleBetweenClockHands (Date.UTC(2016, 3, 5, 15, 0))=> Math.PI / 2
* angleBetweenClockHands(Date.UTC(2016, 3, 5, 18, 0)) => Math.PI
solution:

function angleBetweenClockHands(date) {
    return Math.PI / 180 * (((date.getUTCHours() % 12 || 12) * 30) - (date.getUTCMinutes() * 6));
}

But ESLint swears: Tell me
5dfa67e597b26538336620.png
how to solve the problem

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Savinykh, 2019-12-19
@IsSavinykh

The function is running correctly.
Add before the function:
https://eslint.org/docs/rules/no-mixed-operators - documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question