Sorry this is quit embarrassing, I’m stuck on the invert method and even went through the video but for some reason I still can’t get everything to pass.
this is the invert method
invert(object){
let invertedObject={};
for(let key in object){
const currentValue = object[key]
invertedObject = {currentValue: key}
}
return invertedObject;
}
I just can’t get the pass for this …
4 - Returns an object with all keys and values inverted - Failed: _.invert({originalKey: “originalValue”})[“originalKey”]) returned undefined instead of anotherKey.
I’ve even tried it on vsCode with this:
object ={
name: ‘Bob’,
age: ‘26’,
learning: ‘Coding’
}
const invertedObject = (object) => {
let inverted = {};
for(let key in object){
const currentValue = object[key]
inverted = {currentValue : key}
}
return inverted;
}
console.log(invertedObject(object))
the currentValue and object[key] does give the right output but it seems to be the next line that the currentValue is treating it like a string…
the currentValue in const currentValue = object[key] says its stated but not read elsewhere … doesn’t seem to be picking up the currentValue inside the object?
Thank you!