The aim of this function is to pass in: [{lang: 'English', proficiency: 'Elementary Proficiency'}, {lang: 'Spanish', proficiency: 'Full Professional Proficiency'}].
And have the function print out: [{level: 1, lang: 'English', proficiency: 'Elementary Proficiency'}, { level:3, lang: 'Spanish', proficiency: 'Full Professional Proficiency'}].
However, I'm getting: [{level:3, lang: 'Spanish', proficiency: 'Full Professional Proficiency}, {level:3, lang: 'Spanish', proficiency: 'Full Professional Proficiency}]. ANY IDEAS? Thank you.
lngSort(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 findmax = (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("QUAL: " + JSON.stringify(arr))
}
findmax(proficiencies, userqual);
}