0

I have an AJAX response like this

"12-02-2017,12-02-2017,11-02-2017,10-02-2017"

and i want convert this response into

   var sortDates =["12-02-2017","18-02-2017","11-02-2017","10-02-2017"];

Any questions, please comment.

Reinstate Monica Cellio
  • 25,975
  • 6
  • 51
  • 67
  • [`String.prototype.split()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) – Pointy Jan 30 '17 at 15:20
  • can you help me sort list of dates and implode array Array ( [0] => 10-02-2017 [1] => 11-02-2017 [2] => 12-02-2017 [3] => 04-02-2017 ) array is like this using php?? – Muhammad Awais Zulifqar Jan 30 '17 at 15:45

1 Answers1

4

You can use split():

var resp = "12-02-2017,12-02-2017,11-02-2017,10-02-2017";
resp = resp.split(',');
console.log(resp);
Ionut Necula
  • 11,107
  • 4
  • 45
  • 69