Top community members

Many years me and my friends we were volunteers on my university doing programming classes for young people.

I got main conclusion: Young people are awesome, especially students, because they always bring new and fresh ideas :)
* I loved to do it but my time is limited

  I decided to create something that will help millions of students

Now I am here



JavaScript - how to split string by hyphen sign (minus sign - ascii 45 code)

1 points
Created by:

In JavaScript string has split method. 

String split() function takes as parameter character by which the string will be splitted into array of substrings. As the result of String split() we get array. To access element we just get element by it's index.

Run below example to see how it works in practice.

// ONLINE-RUNNER:browser;

var text = 'split-this-text';
var split = text.split('-');

var element1 = split[0]; // split
var element2 = split[1]; // this
var element3 = split[2]; // text

console.log( element1 );
console.log( element2 );
console.log( element3 );


Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more