JS_HOME_WORK/22-division-remainder/solution.js
2025-02-05 08:47:22 +01:00

24 lines
822 B
JavaScript
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** ЗАДАЧА 22 - Остаток от деления
*
* 1. Выведите в консоль остаток от деления "myNumber1" на "myNumber2".
*
* 2. Какой приоритет и ассоциативность
* имеет оператор остаток от деления?
*
* 3. Проверьте ассоциативность самостоятельно
*/
const myNumber1 = 10 // 10 = 3 + 3 + 3 + 1
const myNumber2 = 3
console.log(myNumber1 % myNumber2)
/**
* Приоритетность оператора % - 13 (выше чем у операторов + и -)
* Ассоциативность оператора % - left-to-right
*
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
*/
console.log(((100 % 23) % 5) % 3)