Question:
Which value does x have after execution of the following code?
function whereIs (name) {
return 'Where is ' + name + '?';
}
let x = whereIs ('Jacky');
Answer:
'Where is Jacky?'
> This is a function declaration & not a function expression
> name of the function: whereIs (camelCase)
> parameter: () parameter is name
> statement: return 'Where is ' + name + '?'; enclosed in curly brackets
> the function must have a return statement that specifies the value to return
> the value type in this case is a string
> strings can be used with single or double quotes
> we can concatenate the string with a '+' sign
> declared a variable x and initialized it with a value
> the value will be, the output we get when we 'call' the function whereIs with the argument
> in this case the argument 'whereIs (name)' is 'whereIs ('Jacky')'
> the value will be 'Where is Jacky?'
No comments:
Post a Comment