how to loop through a array one by one js code example
Example 1: for of loop syntax javascript
for (let step = 0; step < 5; step++) {
// Runs 5 times, with values of step 0 through 4.
console.log('Walking east one step');
}
Example 2: foreach js
// result.params.detail = {
// "status": true,
// "message": "",
// "params": {
// "pay_credit_remain": 115,
// "month_expiry": "15",
// "detail": [
// {
// "credit": "70",
// "create_date": "2020-10-16",
// "expiry_date": "2022-01-16"
// },
// {
// "credit": "45",
// "create_date": "2020-10-17",
// "expiry_date": "2022-01-17"
// }
// ]
// }
//}
detail = "<ul>";
result.params.detail.forEach((val) => {
detail = detail + sprintf(lang.pay_credit_detail, val.credit, val.expiry_date);
});
detail += "</ul>";
$('#pay_credit_remain').html(detail);