function sayHello() {
alert("Welcome to TechTIME");
}
schoolTime.
{
console.log("Welcome to the School on time");
schoolTime();
addition that takes two
arguments num1 and num2. Function will
return sum of both numbers in variable
result
function addition( , ) {
result = num1 + num2
result ;
}
myValue = addition ( 9 , 22 )
subtraction that takes two
arguments num1 and num2.
num2 is set to default value of 9. The function
return sum of num1 and 9 numbers in
variable
result
function addition( num1 , ) {
result = num1 + num2
result ;
}
myValue = addition ( 128 )
console.log ( );
changeColor that will change the
color an element with id glow to blue and
background color to orange
function changeColor ( arg1 , agr2 ) {
element = document.querySelector(' ');
element.style.color = arg1
element.style. = arg2
}
changeColor( 'blue' , 'orange' )
Output:
changeBgColor and
alterBgColor Create a variable
chooseBgColor and ask user to assign the name of color to
the variable. This variable should be passed into
alterBgColor function to alter the provided color. For
example if user supplied red it should change the color
togreen and vice versa. Returned value from
this function should be supplied to
changeBgColor function to apply this new altered color on
an element h1 in HTML.
let chooseBgColor = prompt("Enter the color for background (red/green)");
// This function will just apply the provided color
// to element
function changeBgColor(color1) {
document.querySelector("h1").style.color = color1;
}
// This function will reverse the color
// if user supplies red it will turn it to green
function alterBgColor(color) {
if (color == "red") {
color = "green";
return color;
} else {
color = "red";
return color;
}
}
// calling the function which can reverse or alter the
// provided color
newBgColor = alterBgColor(chooseBgColor);
// Calling the changeColor function and providing altered color to it
changeBgColor(newBgColor);