File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ const Capacity = 6
2+
3+ function sixToast(num) {
4+
5+ let response;
6+ let Capacity - sixToast = howmanymoreorless;
7+
8+ if (howmanymoreorless> 0) {
9+
10+ response = "put `howmanymoreorless` toast";
11+
12+ }
13+
14+ else if (howmanymoreorless = 0){
15+
16+ response = "toast count just right";
17+ }
18+
19+ else (howmanymoreorless < 0) {
20+ response = "toast overflow take 'howmanymoreorless' away"
21+ }
22+
23+ }
24+
25+ console.log(response)
26+
27+
28+
29+
30+ //initial thoughts
31+ //set sixToast = 6 turn into set capacity = 6
32+ //input sixTost =(user input) is parameter , and arguments
33+ //6 - num (argument) = howmanymoreorless
34+ //if howmanymoreorless > 0 return "put `howmanymoreorless` toast"
35+ //if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)"
36+
37+ //keys:
38+ // capacity: number of toast process each time
39+ //sixToast: count of toast put into
40+ //howManymoreorless : the number need more or less
41+
42+ //arithmetics:
43+
44+ // howManymoreorless = sixToast -toastPutinto
45+ // howManymoreorless = sixToast - num
46+ // howManymoreorless = 6 - num
47+
48+ //sixToast -toastPutinto = absolute count of howManymoreorless
Original file line number Diff line number Diff line change 1+ const Capacity = 6
2+
3+ function sixToast ( num ) {
4+ const howmanymoreorless = Capacity - num ;
5+
6+ if ( howmanymoreorless > 0 ) {
7+ return `Put ${ howmanymoreorless } more toast${ howmanymoreorless === 1 ? "" : "s" } .` ;
8+ }
9+
10+ if ( howmanymoreorless === 0 ) {
11+ return "Toast count is just right." ;
12+ }
13+
14+ return `Toast overflow: take ${ Math . abs ( howmanymoreorless ) } toast${ Math . abs ( howmanymoreorless ) === 1 ? "" : "s" } away.` ;
15+ }
16+
17+ console . log ( sixToast ( 2 ) ) ;
18+ console . log ( sixToast ( 6 ) ) ;
19+ console . log ( sixToast ( 7 ) ) ;
20+
21+ //initial thoughts
22+ //set sixToast = 6 turn into set capacity = 6
23+ //input sixTost =(user input) is parameter , and arguments
24+ //6 - num (argument) = howmanymoreorless
25+ //if howmanymoreorless > 0 return "put `howmanymoreorless` toast"
26+ //if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)"
27+
28+ //keys:
29+ // capacity: number of toast process each time
30+ //sixToast: count of toast put into
31+ //howManymoreorless : the number need more or less
32+
33+ //arithmetics:
34+
35+ // howManymoreorless = sixToast -toastPutinto
36+ // howManymoreorless = sixToast - num
37+ // howManymoreorless = 6 - num
38+
39+ //sixToast -toastPutinto = absolute count of howManymoreorless
You can’t perform that action at this time.
0 commit comments