Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Disclosure: My content contains affiliate links.

43,181 questions

56,073 answers

573 users

How to print array of objects with dates in JavaScript

1 Answer

0 votes
const oarr = [
  { day: 772, date: new Date('2022-02-18') },
  { day: 881, date: new Date('2022-01-19') },
  { day: 152, date: new Date('2023-01-30') },
  { day: 208, date: new Date('2022-02-17') },
];

for (let i = 0; i < oarr.length; i++)
	console.log(oarr[i].day  + " " + oarr[i].date.toDateString());

 
  
  
  
/*
run:
  
"772 Fri Feb 18 2022"
"881 Wed Jan 19 2022"
"152 Mon Jan 30 2023"
"208 Thu Feb 17 2022"
  
*/

 



answered Feb 22, 2022 by avibootz
...