function greet(name) {
return 'Hello, ${name}!';
}
console.log(greet("John")); // Output: Hello, John!
let sum = function(x, y) {
return x + y;
};
console.log(sum(3, 5)); // Output: 8
let multiply = function(a, b) {
return a * b;
};
console.log(multiply(2, 4)); // Output: 8
function exponent(base, power) {
return Math.pow(base, power);
}
console.log(exponent(3, 2)); // Output: 9
function sayHello(name) {
console.log('Hello, ${name}!');
}
sayHello("Mohan"); // Output: Hello, Mohan!
function double(num) {
return num * 2;
}
let result = double(7);
console.log(result); // Output: 14
let divide = (x, y) => x / y;
console.log(divide(10, 2)); // Output: 5
function square(num) {
return num * num;
}
console.log(square(4)); // Output: 16