0% found this document useful (0 votes)
13 views

31 Date Assignment (1)

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

31 Date Assignment (1)

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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"))

You might also like