foreach javasc code example
Example 1: for each js
const fruits = ['mango', 'papaya', 'pineapple', 'apple'];
fruits.forEach(function(fruit){
console.log('I want to eat a ' + fruit)
});
Example 2: javascript foreach example
var colors = ["red", "blue", "green"];
colors.forEach(function(color) {
console.log(color);
});
Example 3: javascript foreach index
users.forEach((user, index)=>{
console.log(index);
});
Example 4: foreach js
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);