Skip to content

Commit 023b1cf

Browse files
committed
add an exercice for Switch_cases
1 parent 3a3a4e0 commit 023b1cf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

JavaScript_Basics/switch_case.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,18 @@ switch (true) {
207207
default:
208208
'Tie. Go again.';
209209
}
210+
211+
212+
/* Exercice for you to try to build the switch compeltely*/
213+
214+
// Create a switch statement to convert abriged bytes values (Kb,Mb,Gb,Tb ) to their complete values in bytes, example : 1K = 1 * 1024, 1M = 1 * 1024 * 1024, 1G = 1 * 1024 * 1024 * 1024 , etc...
215+
// how to convert bytes : 1Kb = 1024 b, 1Mb = 1024 Kb, 1Gb = 1024 Mb, 1 Tb = 1024 Gb.
216+
// Hint: the switch will test the value of 'unit', and will have to multiply the var "quantity" by the right number before putting it in the var "result". don't forget to add a default response!
217+
218+
var quantity = 2;
219+
var unit = "Kb";
220+
var result;
221+
222+
//put your Switch here
223+
224+

0 commit comments

Comments
 (0)