I have situation about converting number to string. In the function below. I am iterating the objects and trying to change value type of plan_price. it's working when I do console.log()
bestPlanArrange(bridals){
let plans = [];
bridals.filter(item => {
item.plans.filter(plan => {
plans.push(plan);
});
})
let obj = {}
let planArr = [];
plans.filter(item => {
item.plan_price.toString()
console.log(item.plan_price) // doesn't listen the code above not working.
console.log(item.plan_price.toString()) // it's working like this.
planArr.push(item) // I want to push after covert.
})
if (planArr[0] != null && plans[0].plan_price != null) {
obj = planArr[0];
}
return obj;
},
Do I missing something or doing something wrong here?
filterwhen the function doesn't return atrue/falsevalue and you're not using the result? It seems like you're using it when you really meanforEach..map().let planArr = plans.map(item => item.plan_price.toString())