Skip to content

Commit 1e08a60

Browse files
remove empty elements examp added
1 parent 4e45245 commit 1e08a60

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

remove_empty.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//remove empty array
2+
//process - 1
3+
const list = ["name", "todo", NaN, undefined, "sunday", ""];
4+
console.log(list);
5+
// 'name', 'todo', NaN, undefined, 'sunday', ''
6+
let newList = [];
7+
for (i in list) {
8+
if (list[i]) {
9+
newList.push(list[i]);
10+
}
11+
}
12+
13+
console.log(newList);
14+
//'name', 'todo', 'sunday'

0 commit comments

Comments
 (0)