The objective of this operation is to input:
[{lang: 'English', proficiency: 'Elementary Proficiency'}, {lang: 'Spanish', proficiency: 'Full Professional Proficiency'}]
.
Then, the goal is to output:
[{level: 1, lang: 'English', proficiency: 'Elementary Proficiency'}, { level:3, lang: 'Spanish', proficiency: 'Full Professional Proficiency'}]
.
However, the current output is:
[{level:3, lang: 'Spanish', proficiency: 'Full Professional Proficiency}, {level:3, lang: 'Spanish', proficiency: 'Full Professional Proficiency}]
. Any suggestions? Thank you.
updateSort(exObj) {
let userprof = []
let lng = []
const proficiencies = [
{ level: 1, name: 'Elementary Proficiency' },
{ level: 2, name: 'Limited Working Proficiency' },
{ level: 3, name: 'Full Professional Proficiency' },
{ level: 4, name: 'Native Bilingual Proficiency' }
]
for(let v in exObj) {
userprof.push(exObj[v].proficiency);
lng.push(exObj[v].lang);
}
let findMaxProficiency = (proficiencies, userprof) => {
const arr = [];
const ob = {};
let found = false;
for (const prof of proficiencies) {
for (const user of userprof) {
if (found) found = false
for (const l of lng) {
if (prof.name === user) {
ob.level = qual.level
ob.proficiency = qual.name
ob.lang = l
arr.push(ob);
found = true
break
}
}
}
}
console.log("PROFICIENCIES FOUND: " + JSON.stringify(arr))
}
findMaxProficiency(proficiencies, userqual);
}