const participants = [
{id: 1, name: 'Anakin Skywalker'},
{id: 2, name: 'Padmé Amidala'},
{id: 3, name: 'Luke Skywalker'},
{id: 4, name: 'Princess Leia'},
]
const hotel = [
{
room: [
{id: '', name: ''}
]
},
{
room: [
{id: '', name: ''},
{id: '', name: ''}
]
},
{
room: [
{id: '', name: ''}
]
}
]
const result = hotel.map(h => {
return h.room.map((r) => {
r.id = participants[0].id
r.name = participants[0].name
participants.shift()
return r
})
})
console.log(result)
[[{"id":1,"name":"Anakin Skywalker"}],
[{"id":2,"name":"Padmé Amidala"},{"id":3,"name":"Luke Skywalker"}],
[{"id":4,"name":"Princess Leia"}]]
const arr = [
{ id0: 200, sum0: 1000 },
{ id0: 200, sum0: 1000 },
{ id0: 200, sum0: 1000 },
{ id0: 200, sum0: 1000 },
{ id10: 300, sum300: 1500 },
{ id10: 300, sum300: 1500 },
{ id10: 300, sum300: 1500 },
];
const calc = arr.reduce(
(acc, current) => {
const key = Object.keys(current).find((key) => key.startsWith("id"));
acc[key] ? acc[key]++ : (acc[key] = 1);
if (acc[key] > acc.result.count) acc.result = { id: key, count: acc[key] };
return acc;
},
{ result: { id: null, count: 0 } }
);
console.log(calc.result)
RewriteEngine On
RewriteRule ^article-(.*)/gallery /article-$1 [R=permanent]
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>