let allUserData = [];
const logStuff = (supply) => {
if (typeof supply === 'string') {
console.log(supply)
} else if (typeof suppy === 'object') {
for (let item in supply) {
console.log(item + ':' + supply[item])
}
}
}
const getInput = (options, callback) => {
allUserData.push(options);
callback(options);
}
getInput('Brian', logStuff)
getInput({ colour: 'cyan'}, logStuff)
This is a simple program I wrote that utilizes a callback function to print whatever argument is supplied (string or object).
It prints the string but not the object. Please help