Complete the code to return the sum of two numbers.
function add(a, b) {
return a [1] b;
}The return statement sends the result back to where the function was called. Using + adds the two numbers.
Complete the code to return the length of the string.
function getLength(str) {
return str[1];
}.size or .count.In JavaScript, strings have a length property (without parentheses) that gives the number of characters.
Fix the error in the function to correctly return the square of a number.
function square(num) {
[1] num * num;
}console.log instead of return.The function must use return to send the result back. console.log only prints to the console but does not return a value.
Fill both blanks to create a function that returns true if a number is even.
function isEven(num) {
return num [1] 2 [2] 0;
}= instead of comparison.== instead of strict equality ===.The modulo operator % gives the remainder. If num % 2 === 0, the number is even.
Fill both blanks to return an object with the uppercase key and its length as value for a given word.
function wordInfo(word) {
return { [1]: : [2] };
}* instead of colon : in object.toUpperCase() as a function.The function returns an object with a key and value. The key is the uppercase word, then a colon :, then the length of the word as the value.