How would you declare a variable called fullName that contains both John's first and last name?

Prepare for the WDI General Assembly Assessment Test. Study using flashcards and multiple choice questions with hints and detailed explanations. Master your skills and boost your chances of success in the exam!

The chosen answer accurately demonstrates how to concatenate two strings to create a single variable that holds a full name. In this case, firstName and lastName represent variables that would contain John's first name ("John") and last name ("Smith"). By using the + operator, you can combine these two variables into one string, with a space in between to format it correctly. The addition of the string " " ensures that the first name and last name are separated properly when combined, resulting in "John Smith".

This approach effectively uses string concatenation to build the desired output, which is especially useful when dealing with dynamic data where the names might not be hardcoded. Placing the space in quotes ensures that it is interpreted as a string itself and included in the final output. Thus, the result stored in fullName will be the correctly formatted representation of John’s complete name.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy