You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Return true if the passed string looks like a valid US phone number.
4
+
5
+
The user may fill out the form field any way they choose as long as it has the format of a valid US number. The following are examples of valid formats for US numbers (refer to the tests below for other variants):
6
+
7
+
555-555-5555
8
+
(555)555-5555
9
+
(555) 555-5555
10
+
555 555 5555
11
+
5555555555
12
+
1 555 555 5555
13
+
14
+
For this challenge you will be presented with a string such as 800-692-7753 or 8oo-six427676;laskdjf.
15
+
Your job is to validate or reject the US phone number based on any combination of the formats provided above.
16
+
The area code is required. If the country code is provided, you must confirm that the country code is 1.
17
+
Return true if the string is a valid US phone number; otherwise return false.
18
+
19
+
- telephoneCheck("555-555-5555") should return a boolean.
20
+
- telephoneCheck("1 555-555-5555") should return true.
21
+
- telephoneCheck("1 (555) 555-5555") should return true.
22
+
- telephoneCheck("5555555555") should return true.
23
+
- telephoneCheck("555-555-5555") should return true.
24
+
- telephoneCheck("(555)555-5555") should return true.
25
+
- telephoneCheck("1(555)555-5555") should return true.
26
+
- telephoneCheck("555-5555") should return false.
27
+
- telephoneCheck("5555555") should return false.
28
+
- telephoneCheck("1 555)555-5555") should return false.
29
+
- telephoneCheck("1 555 555 5555") should return true.
30
+
- telephoneCheck("1 456 789 4444") should return true.
31
+
- telephoneCheck("123**&!!asdf#") should return false.
32
+
- telephoneCheck("55555555") should return false.
33
+
- telephoneCheck("(6054756961)") should return false.
34
+
- telephoneCheck("2 (757) 622-7382") should return false.
35
+
- telephoneCheck("0 (757) 622-7382") should return false.
36
+
- telephoneCheck("-1 (757) 622-7382") should return false.
37
+
- telephoneCheck("2 757 622-7382") should return false.
38
+
- telephoneCheck("10 (757) 622-7382") should return false.
39
+
- telephoneCheck("27576227382") should return false.
40
+
- telephoneCheck("(275)76227382") should return false.
41
+
- telephoneCheck("2(757)6227382") should return false.
42
+
- telephoneCheck("2(757)622-7382") should return false.
43
+
- telephoneCheck("555)-555-5555") should return false.
44
+
- telephoneCheck("(555-555-5555") should return false.
45
+
- telephoneCheck("(555)5(55?)-5555") should return false.
46
+
- telephoneCheck("55 55-55-555-5") should return false.
Design a cash register drawer function checkCashRegister() that accepts purchase price as the first argument (price),
4
+
payment as the second argument (cash), and cash-in-drawer (cid) as the third argument.
5
+
6
+
cid is a 2D array listing available currency.
7
+
8
+
The checkCashRegister() function should always return an object with a status key and a change key.
9
+
10
+
Return {status: "INSUFFICIENT_FUNDS", change: []} if cash-in-drawer is less than the change due, or if you cannot return the exact change.
11
+
12
+
Return {status: "CLOSED", change: [...]} with cash-in-drawer as the value for the key change if it is equal to the change due.
13
+
14
+
Otherwise, return {status: "OPEN", change: [...]}, with the change due in coins and bills, sorted in highest to lowest order, as the value of the change key.
15
+
16
+
Currency Unit Amount
17
+
Penny $0.01 (PENNY)
18
+
Nickel $0.05 (NICKEL)
19
+
Dime $0.1 (DIME)
20
+
Quarter $0.25 (QUARTER)
21
+
Dollar $1 (ONE)
22
+
Five Dollars $5 (FIVE)
23
+
Ten Dollars $10 (TEN)
24
+
Twenty Dollars $20 (TWENTY)
25
+
One-hundred Dollars $100 (ONE HUNDRED)
26
+
See below for an example of a cash-in-drawer array:
0 commit comments