Appending Variables to Strings
Just as we can build a string over multiple lines out of string literals, we can also append variables to a string using the plus equals (+=
) operator.
Example:
const anAdjective = "awesome!";
let ourStr = "freeCodeCamp is ";
ourStr += anAdjective;
ourStr
would have the value freeCodeCamp is awesome!
.
Set someAdjective
to a string of at least 3 characters and append it to myStr
using the +=
operator.
Tests
- Waiting: 1.
someAdjective
should be set to a string at least 3 characters long. - Waiting: 2. You should append
someAdjective
tomyStr
using the+=
operator.
/** * Your test output will go here */