Hi Everyone...

I need your help please... I want to store my extracted string using list() function...
Here is my code below and it doesn't work.. Is there a list() function in Javascript?

var Mystring;
  var H;
  var M;
  var S;
  Mystring="01:00:00";
  list(H,M,S)=Mystring.split(":");
 
  document.write("Hours: "+H);
  document.write(" Minutes: "+M);
  document.write(" Seconds: "+S);

My expected output:
Hours: 01 Minutes: 00 Seconds: 00

Help me please.. Thank's in advance..

Use an array.

var Mystring;
Mystring="01:00:00";
var myArray=Mystring.split(":");

document.write("Hours: "+myArray[0]);
document.write(" Minutes: "+myArray[1]);
document.write(" Seconds: "+myArray[2]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.