DekGenius.com
JAVASCRIPT
javascript string to array
var a = "['a', 'b', 'c']";
a = a.replace(/'/g, '"');
a = JSON.parse(a);
js string to array
var myString = 'no,u';
var MyArray = myString.split(',');//splits the text up in chunks
js string to array
str = 'How are you doing today?';
console.log(str.split(' '));
>> (5) ["How", "are", "you", "doing", "today?"]
js string to array
// string
let string = '12345';
// splits characters string into items in our array
let array = string.split('');
console.log(array); // [ "1", "2", "3", "4", "5"]
convert a string to an array javascript
function stringToArray(string){
const arr = string.split(" ");// add space in between qoutes to avoid splits every letters in string
return arr
}
//splitting
const str = stringToArray('hello world!');
console.log(str); //output: [ 'hello', 'world!' ]
Convert string to array
var fruits = 'apple, orange, pear, banana, raspberry, peach';
var ar = fruits.split(', '); // split string on comma space
console.log( ar );
// [ "apple", "orange", "pear", "banana", "raspberry", "peach" ]
convert a string to array in javascript
// Designed by shola for shola
str = 'How are you doing today?';
console.log(str.split(" "));
//try console.log(str.split("")); with no space in the split function
//try console.log(str.split(",")); with a comma in the split function
convert string to array
let string = "Hello World!"
let arr = string.split(' '); // returns ["Hello","World!"]
let arr = string.split(''); // returns ["H","e","l","l"," ","W","o","r","l","d","!"]
let string = "Apple, Orange, Pear, Grape"
let arr = string.split(','); // returns ["Apple","Orange","Pear","Grape"]
javascript string to array
const str = 'Hello!';
const arr = Array.from(str);
//[ 'H', 'e', 'l', 'l', 'o', '!' ]
string to array
public List<string> ArrayFromString(string str)
{
var sb = new StringBuilder();
var ls = new List<string>();
for (int i = 0; i < str.Length; i++)
{
if(str[i]>=65 && str[i]<=90 || str[i]>=97 && str[i]<=122)
sb.Append(str[i]);
else
{
if(sb.Length>0)
ls.Add(sb.ToString());
sb.Clear();
}
}
if(sb.Length>0)
{
ls.Add(sb.ToString());
}
return ls;
}
string to array
let str ='a,b,c,d'
let result =str.split(',');
//output:
['a','b','c','d']
string to array in js
convert string to array
string to array in js
Object.assign([], 'string').bold;
// (method) String.bold(): string
String to array
const str = "Kamran";
let arr = [];
let k = 0;
for (let i of str) {
arr[k++] = i;
}
console.log(arr)
string[] to array
String[] words = {"ace", "boom", "crew", "dog", "eon"};
List<String> wordList = Arrays.asList(words);
how to convert string to array
let str = "hello there how are you'll";
let array = [...str]
convert a string to array
b="1,2,3,4".split(',').map(x=>+x)
// Output : [1,2,3,4]
© 2022 Copyright:
DekGenius.com