Backend Week3 JavaScript Tasks
Backend Week3 JavaScript Tasks
Problem Set 1:
2. Define a loop which will print out 1 - 100. Also define a loop which will print
out 1 - 10 to the console without printing out the numbers 4 and 5.
3. Using a loop and the modulus operator, write a program which will print out
only the even numbers between 10 and 20 and the odd numbers between 20
and 30.
NB: Use only one loop
4. Declare 20 variables using let and assign different reasonable values to them.
5. Declare 10 arrays and assign at least 6 values in each of them. Each array
should have only values of the same data type. Let array values range from
numbers, strings, Booleans to even functions. Let some of the values be
added to the arrays using the push() operation.
7. Access at least 10 of the values each from the arrays and from the objects
and print to the console.
Problem Set 2
1. Create a program which checks the day of the week using a switch case block
and prints the equivalent day of the week.
2. Create a program which checks the month of the year using a switch case
block and prints the equivalent month of the year.
3. Create a program which checks the day of the week using a switch case block
and prints the equivalent day of the week, but include a fall through system
where if the day of the week is Saturday, the program falls through to print
Sunday after printing Saturday.
4. You arrive in front of a bridge that you must cross to reach a village before
dark. Crossing the bridge is not free - the bridgekeeper asks you to roll two
dice to determine the cost.
You decide to write a program to verify that he is charging the right price.
Your program should read two integers, between 1 and 6, representing the
values of each die. If the sum is greater than or equal to 10, then you must
pay a special fee (36 coins). Otherwise, you pay twice the sum of the values of
the two dice. Your program must then display the text "Special tax" or
"Regular tax" followed by the amount you have to pay on the next line.
EXAMPLE
INPUT
OUTPUT
Special tax
36
INPUT
4
3
OUTPUT
Regular tax
14
Problem Set 3
1. Define a for loop which will print out only the even numbers between 0 and
50.
a. Use the modulus (%) operator in this operation.
b. Do not use the modulus operator in this operation.
Note: that this will leave you with 2 separate answers to this (7)
question.
2. Define a loop which will print out the sum of all the numbers between 0 and
20.
3. Define a loop which will print out all the odd numbers between 0 and 100.
If you have any questions, please ask. But digest the assignment properly before
asking.