4.
sortaSum
Given 2 ints, a and b, return their sum. However, sums in the range 10..19
inclusive, are forbidden, so in that case just return 20.
Ikkita a va b butun son berilgan, ularning yig`indisini
qaytaring.Agar, ularning yig`indisi 10…19 oraliqda o`zgarsa,
yig`indi o`chirilib o`rniga 20 qiymat qaytarilsin.
sortaSum(3, 4) → 7
sortaSum(9, 4) → 20
sortaSum(10, 11) → 21
5.
alarmClock
Given a day of the week encoded as 0=Sun, 1=Mon, 2=Tue, ...6=Sat, and a
boolean indicating if we are on vacation, return a string of the form "7:00"
indicating when the alarm clock should ring. Weekdays, the alarm should be
"7:00" and on the weekend it should be "10:00". Unless
we are on vacation
-- then on weekdays it should be "10:00" and weekends it should be "off".
Hafta kunlari quyidagicha berilgan bo`lib, 0=Sun, 1=Mon, 2=Tue,
..6=Sat, va Boolean mantiqiy qiymati biz ta`tilda yoki yoqligini
ifodalaydi. Agar budilnik jiringlashi kerak bo`lsa “7:00” satrli qiymat
qaytaring. Ish kunlari budilnik “7:00” da va dam olish kunlari
“10:00”da jiringlaydi. Tatil vaqtidaish kunlarida “10:00” da jiringlab
dam olish kunlari esa “off” bo`lishi kerak.
alarmClock(1, false) → "7:00"
alarmClock(5, false) → "7:00"
alarmClock(0, false) → "10:00"
6.
love6
The number 6 is a truly great number. Given two int values, a and b, return
true if either one is 6. Or if their sum or difference is 6. Note: the function
Math.abs(num) computes the absolute value of a number.
Dostları ilə paylaş: