[Fix] Corrected bug found in Shopping List challenge (#35017)

* fix: corrected bug found in issue #16044

* fix: account for empty strings

Co-Authored-By: RandellDawson <5313213+RandellDawson@users.noreply.github.com>

* fix: corrected wrong logic
pull/35307/head
Randell Dawson 2019-02-23 23:58:55 -08:00 committed by Aditya
parent 5b73ed54e2
commit b83ab53047
1 changed files with 4 additions and 4 deletions

View File

@ -64,14 +64,14 @@ var hasNumber = false;
if(myList.length > 0) {
hasString = true;
hasNumber = true;
myList.forEach(function(elem) {
if(typeof elem[0] !== 'string') {
for (var elem of myList) {
if(!elem || !elem[0] || typeof elem[0] !== 'string') {
hasString = false;
}
if(typeof elem[1] !== 'number') {
if(!elem || typeof elem[1] !== 'number') {
hasNumber = false;
}
});
}
}
count = myList.length;
return JSON.stringify(myList);