Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

Add the converted string into a new array
Source Link
palaѕн
  • 74.2k
  • 17
  • 123
  • 140

Try this using jQuery:

var arr = ["Jan 2011", "Feb 2011", "Mar 2011"];
var name = ["JANUARY", "FEBRUARY", "MARCH"];
var list = new Array();

// Loop through the array arr
$.each(arr, function(i, value) {
 
 // Convert the month names
 var month = name[i];
 var year = value.split(" ")[1];
 // Display the result
 alert(month + ' ' + year); 
 // Add elements to a new array
 list.push(month + ' ' + year);
});​
console.log(list);

Console Result:

["JANUARY 2011", "FEBRUARY 2011", "MARCH 2011"]

Hope this helps!

Try this using jQuery:

var arr = ["Jan 2011", "Feb 2011", "Mar 2011"];
var name = ["JANUARY", "FEBRUARY", "MARCH"];
// Loop through the array arr
$.each(arr, function(i, value) {
 
 // Convert the month names
 var month = name[i];
 var year = value.split(" ")[1];
 // Display the result
 alert(month + ' ' + year); 
});​

Hope this helps!

Try this using jQuery:

var arr = ["Jan 2011", "Feb 2011", "Mar 2011"];
var name = ["JANUARY", "FEBRUARY", "MARCH"];
var list = new Array();

// Loop through the array arr
$.each(arr, function(i, value) {
 
 // Convert the month names
 var month = name[i];
 var year = value.split(" ")[1];
 // Display the result
 alert(month + ' ' + year); 
 // Add elements to a new array
 list.push(month + ' ' + year);
});​
console.log(list);

Console Result:

["JANUARY 2011", "FEBRUARY 2011", "MARCH 2011"]

Hope this helps!

Source Link
palaѕн
  • 74.2k
  • 17
  • 123
  • 140

Try this using jQuery:

var arr = ["Jan 2011", "Feb 2011", "Mar 2011"];
var name = ["JANUARY", "FEBRUARY", "MARCH"];
// Loop through the array arr
$.each(arr, function(i, value) {
 
 // Convert the month names
 var month = name[i];
 var year = value.split(" ")[1];
 // Display the result
 alert(month + ' ' + year); 
});​

Hope this helps!

lang-js

AltStyle によって変換されたページ (->オリジナル) /