How to remove empty strings from converted sorted arrays?

Hi, I’m trying to remove empty strings from this converted string to array problem.

Previously I’ve done removing the empty strings from array by filter() property like the below code.

var n = ["hi", , "what"];
var y = n.filter(Boolean);

But now on this problem which is required to convert from string array first and then remove the empty string from it. I tried with the below code. but it’s not removing the empty strings.

var s = "Hello world, how you doin?";
var a = s.split("");
var x = a.filter(Boolean);

I appreciate your help! Gracious.

There are no empty strings in your output, so they did all get removed.

Thank you @ionatan for the reply. I’m confused though . aren’t index 0-3 empty string?

  ' ', ' ', ' ', ' ', ',', '?',
  'H', 'd', 'd', 'e', 'h', 'i',
  'l', 'l', 'l', 'n', 'o', 'o',
  'o', 'o', 'o', 'r', 'u', 'w',
  'w', 'y'
] ```

Update: I found my mistake. there should be
var a = s.split(""); a space in the quote . it works fine adding a space inside the qoute. Thanks a lot

they all have a length of 1

1 Like