I have the following code:
let pa = 0;
let pw = 0;
let pc = 0;
let pi = 0;
let pr = 0;
this.state.array.data.map((i) => {
if (i.mdn === this.queryParams.mdn && i.sources != null) {
return (i.sources.map((sources) => {
if (sources.source.toString().toLowerCase() === "a") {
pa = sources.t.sessions.u
}
if (sources.source.toString().toLowerCase() === "w") {
pw = sources.t.sessions.u
}
if (sources.source.toString().toLowerCase() === "c") {
pc = sources.t.sessions.u
}
if (sources.source.toString().toLowerCase() === "i") {
pi = sources.t.sessions.u
}
if (sources.source.toString().toLowerCase() === "r") {
pr = sources.t.sessions.u
}
}))
}
},
this.setState({
web: [],
app: [],
preference: [{a: pa}, {w: pw}, {c: pc}, {i: pi}, {r: pr}]
}),
Once I get to set state, it doesn't actually set it, it just takes the 0 and throw throws in there.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)