Exercise

Stop pasting, start gluing

The function paste() concatenates strings with a space in between, so paste("Hi", "there") will output "Hi there". There is also the paste0() function that doesn't add a space, the result of which would be "Hithere". But when you concatenate multiple strings and variables, you end up writing a lot of double quotes " and commas , and with code that is not very readable. Plus you can only work with variables that are already present.

These are the two use cases where the glue() function really shines. You can either work with variables that are available in the global scope or you can create variables on the fly. In this exercise, you'll see the difference between paste() and glue() in action.

Instructions

100 XP
  • Recreate the sentence that was created with paste0() using glue().
  • Create a temporary variable n which stores the length of characters in firstname and pass it sentence being created.