[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 logicpull/35307/head
parent
5b73ed54e2
commit
b83ab53047
|
@ -64,14 +64,14 @@ var hasNumber = false;
|
||||||
if(myList.length > 0) {
|
if(myList.length > 0) {
|
||||||
hasString = true;
|
hasString = true;
|
||||||
hasNumber = true;
|
hasNumber = true;
|
||||||
myList.forEach(function(elem) {
|
for (var elem of myList) {
|
||||||
if(typeof elem[0] !== 'string') {
|
if(!elem || !elem[0] || typeof elem[0] !== 'string') {
|
||||||
hasString = false;
|
hasString = false;
|
||||||
}
|
}
|
||||||
if(typeof elem[1] !== 'number') {
|
if(!elem || typeof elem[1] !== 'number') {
|
||||||
hasNumber = false;
|
hasNumber = false;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
count = myList.length;
|
count = myList.length;
|
||||||
return JSON.stringify(myList);
|
return JSON.stringify(myList);
|
||||||
|
|
Loading…
Reference in New Issue