I have this problem that I can't figure out how to determine if the object only has strings. I am trying not only to get help on figuring this out, but if someone has time, they could explain why their answer works, to help me learn. Thank you
function hasOnlyStrings(o) {
for (var val in o) {
var values = o[match];
if (typeof values === 'string') {
return true;
}
else { return false; }
}
}
var car = {
name: 'corvette',
fast: true,
color: 'black'
}
var truck = {
name: 'ford',
color: 'blue'
}