skip to Main Content

Between 2 JavaScript Arrays

<script> var array1 = ['2023-04-05','2023-04-06','2023-04-07','2023-04-08']; //array1 var array2 = ['2023-04-06','2023-04-07']; //array2 found1 = array1.find((val, index) => { //find the date in array1 return array2.includes(val); }); $('.show').html(found1); </script> result 2023-04-062023-04-07 how to result like this 2023-04-06, 2023-04-07

VIEW QUESTION

Merge 2 array of objects with different properties – Javascript

I have 2 arrays of objects: array1 = [{"id":1,"cost":200,"qty":56},{"id":2,"cost":100,"qty":16}]; array2 = [{"id":1,"cost":200,"desc":"a good one"},{"id":2,"cost":100,"desc":"a bad one"},{"id":3,"cost":50,"desc":"an okay one"}]; I want to merge them so it looks like this: [{"id":1,"cost":200,"qty":56,"desc":"a good one"},{"id":2,"cost":100,"qty":16,"desc":"a bad one"}]; Please notice the new array has properties…

VIEW QUESTION
Back To Top
Search