Write a function isEmpty(arr) that returns true if the array is empty, and false if is not empty or is undefined.Need help... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Write a function isEmpty(arr) that returns true if the array is empty, and false if is not empty or is undefined.Need help...

function isEmpty(arr) { return true } Here is what i tried(how can i do multiple return): function isEmpty(arr) { arr = [[], [0, 1], ['a', 'b'], [undefined]] for (var i = 0; i < arr.length; i++) { var elem = arr[i] if (elem == arr[0]) { return true } } }

21st Jul 2020, 12:04 PM
Apongpoh Gilbert
Apongpoh Gilbert - avatar
1 Answer
+ 1
You could store the returns in an array/list and return the array/list itself. let return = [true , false , false , true];
21st Jul 2020, 12:07 PM
Ćheyat
Ćheyat - avatar