Question:
Which value does x have after execution of the following code?
function reply(phrase) {
return phrase;
}
let x = reply('How do you do?');
Answer:
'How do you do?'
> This is a function declaration & not a function expression
> name of the function: reply
> parameter: () parameter is phrase
> statement: return phrase; enclosed in curly brackets
> the function must have a return statement that specifies the value to return
> declared a variable x and initialized it with a value
> the value will be, the output we get when we 'call' the function reply with the argument
> in this case the argument 'reply(phrase)' is 'reply('How do you do?')'
No comments:
Post a Comment