Learn the Date Object by Building a Date Formatter - Step 19

Tell us what’s happening:

I know how to pass this test . But I have a question. Please help me . When I pass the empty string in the .split() method . It returns the each letter into an array. But when I use a string that contains space like: “Hello World”.split(" ") then it will return [ ‘Hello’ , ‘World’] why is this? what that space done so that it happens?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const exampleSentence = "selur pmaCedoCeerf".split();
console.log(exampleSentence);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Learn the Date Object by Building a Date Formatter - Step 19

the difference is the argument of split. In one case you are using .split(), the default behaviour is to separate into each character. But when you write .split(" ") then it separates using the space character

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.