Question:
Which value does x have after execution of the following code?
function double(name) {
return name + ' and ' + name;
}
let x = double('Roy');
Answer:
'Roy and Roy'
> function name is double
> it is a function expression
> parameter is name
> statement is return name + ' and ' + name; enclosed in curly brackets
> this function returns a statement that has concatenated two parameters with 'and using '+' sign
> declared a variable x and initialized it with a value
> the value will be, the output we get when we 'call' the function double with the argument
No comments:
Post a Comment