Task: if a more than b more than 10 , output a + 10 ; otherwise, if a less than b , print 9 ; otherwise b )
if (a > b && a > 10) { console.log(a + 10); } else { console.log(a + 9); } Task: if a more than b more than 10 , output a + 10 ; otherwise, if a less than b , print 9 ; otherwise b )
if (a > b && a > 10) { console.log(a + 10); } else { console.log(a + 9); } function getNumber(a, b) { if (a - 10 > b) return a + 10; if (a < b) return 9; return b; } console.log(getNumber(12, 1)); // 22 console.log(getNumber(1, 11)); // 9 console.log(getNumber(12, 5)); // 5 10 from a , then the resulting value must be greater than b . You can write in a different way. a > b + 10 . - Suvitruf ♦If a is more than b by more than 10 (pseudocode)
(a - b > 10) -> a + 10 If a is less than b
(a < b) -> 9 Source: https://ru.stackoverflow.com/questions/881760/
All Articles
const f = (a, b) => a - 10 > b ? a + 10 : a < b ? 9 : b;- Yaant September