Answers for "word to char array javascript"

5

string to char array in javascript

const string = 'hi there';

const usingSplit = string.split('');              
const usingSpread = [...string];
const usingArrayFrom = Array.from(string);
const usingObjectAssign = Object.assign([], string);

// Result
// [ 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e' ]
Posted by: Guest on October-25-2020
2

word to char array javascript

var word = userInput[0];
  var l = word.split("");
  console.log(l);

//input abb
//op ['a','b','b']
Posted by: Guest on December-07-2020
0

convert string to char array javascript

const string = 'word';

// Option 1
string.split('');

// Option 2
[...string];

// Option 3
Array.from(string);

// Option 4
Object.assign([], string);

// Result:
// ['w', 'o', 'r', 'd']
Posted by: Guest on May-02-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language