Q1
---
// Define a "weekDay" having two parameter. when we input a value between 1-7 it
will give a output as day of the week.
function weekDay(day){
//Every given number will return a day of the week.
switch(day){
case 1:
return "MONDAY"
case 2:
return "TUESDAY"
case 3:
return "WEDNESDAY"
case 4:
return "THURSDAY"
case 5:
return "FRIDAY"
case 6:
return "SATURDAY"
case 7:
return "SUNDAY"
}
}
// printing the days
console.log(weekDay(1))
console.log(weekDay(2))
console.log(weekDay(3))
console.log(weekDay(4))
console.log(weekDay(5))
console.log(weekDay(6))
console.log(weekDay(7))
----------------------------------------------------------------------------------
Q2
---
// Define a function "Calculator" having 3 parametres. we have to input two values
and a operator.
function Calculator(value1, value2, operator){
// Initialising two variable num1 and num2
var num1 = value1
var num2 = value2
// Input a operator to get the solution of to values.
switch(operator){
case '+':
return num1+num2
case '-':
return num1-num2
case '*':
return num1*num2
case '/':
return num1/num2
}
}
// printing the solution of two values
console.log("Addition of two values is",Calculator(11,5,'+'))
console.log("subtraction of two values is",Calculator(11,5,'-'))
console.log("Multiplication of two values is",Calculator(11,5,'*'))
console.log("Division of two values is",Calculator(11,5,'/'))
-----------------------------------------------------------------------------------
--
Q3
---
// Define a function "ColorPicker" having a parametre. which return a colour on
entering a colour code.
function ColorPicker(colorCode){
// Checks colorCode then returns a colour.
switch(colorCode){
case "R":
return "RED COLOUR"
case "O":
return "ORANGE COLOUR"
case "Y":
return "YELLOW COLOUR"
case "G":
return "GREEN COLOUR"
case "B":
return "BLUE COLOUR"
case "I":
return "INDIGO COLOUR"
case "V":
return "VIOLET COLOUR"
}
}
// Printing colour name by inputing colorCode.
console.log(ColorPicker("V"))
console.log(ColorPicker("I"))
console.log(ColorPicker("B"))
console.log(ColorPicker("G"))
console.log(ColorPicker("Y"))
console.log(ColorPicker("O"))
console.log(ColorPicker("R"))