Answers for "split string javascript by comma"

12

javascript split by comma

<script>
var names = 'Harry,John,Clark,Peter,Rohn,Alice';
var nameArr = names.split(',');
console.log(nameArr);
 
// Accessing individual values
alert(nameArr[0]); // Outputs: Harry
alert(nameArr[1]); // Outputs: John
alert(nameArr[nameArr.length - 1]); // Outputs: Alice
 
var str = 'Hello World!';
var chars = str.split('');
console.log();
 
// Accessing individual values
alert(chars[0]); // Outputs: H
alert(chars[1]); // Outputs: e
alert(chars[chars.length - 1]); // Outputs: !
</script>
Posted by: Guest on March-31-2020
2

separatly fetch a strings with commas inn js

$(function(){
    var s = "jpeg, jpg, gif, png";
    var match = s.split(', ')
    console.log(match)
    for (var a in match)
    {
        var variable = match[a]
        console.log(variable)
    }
})
Posted by: Guest on May-29-2020
2

javascript split string into array by comma and space

input.split(/[ ,]+/); //splits string using RegEx on a space OR a comma
Posted by: Guest on June-11-2020
-1

convert comma separated string to array c#

string fruit = "Apple,Banana,Orange,Strawberry";
string[] split = fruit.Split(',');
Posted by: Guest on May-29-2020
1

javascript split

var arr = ['hey', 'nay', 'wey'];
var let = arr.split(' ');
console.log(let);
Posted by: Guest on September-20-2020

Code answers related to "split string javascript by comma"

Code answers related to "Javascript"

Browse Popular Code Answers by Language