Created
December 18, 2019 12:20
-
-
Save kevinchisholm/4f85f85f22d4f6b8fd290f9e56e797ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example # 4: Make sure that the passed-in object is an instance of the Array constructor | |
function processRecords (records) { | |
if (!(records instanceof Array)) { | |
console.log(`Array provided array not valid`); | |
return; | |
} | |
if (!records.length) { | |
console.log(`No records to process`); | |
return; | |
} | |
records.forEach(record => { | |
console.log(`The record is: ${record}`); | |
}); | |
} | |
processRecords({length: 3}); | |
// Array provided array not valid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment