Build a Reminder with Template Literals
Build a library reminder
A library has a reader, a book title, and a pickup deadline. Put those inputs into one message without joining text fragments with +.
javascript
function holdReminder(reader, book, deadline) {
return `Hi ${reader.trim()}, ${book} is ready. Pick it up by ${deadline}.`;
}
console.log(holdReminder(" Maya ", "Field Guide", "Friday"));
Before running, locate the three substitutions. Only the reader's name calls trim(); the book title and deadline are inserted as provided.
Run and check that the output begins Hi Maya, rather than keeping the spaces around the supplied name. The function returns the message; the outer console.log() displays it. Keeping those jobs separate lets you use the returned string in a longer list, which you will do in the pantry exercise next.