Solution Review: Check the Names
This lesson will explain the solution to the problem in the previous lesson.
We'll cover the following...
Solution #
Press + to interact
const checkName = (firstName, lastName, callback) => {if (!firstName) return callback(new Error('No First Name Entered'))if(!lastName) return callback(firstName)const fullName = `${firstName}` + `${lastName}`return callback(fullName)}function callback(arg){console.log(arg)}
Explanation #
We need to cater to three conditions:
-
If the first name is not given
-
If the last name is not given
-
If both ...