javascript - Object only has strings detection -
i have problem can't figure out how determine if object has strings. trying not on figuring out, if has time, explain why answer works, me learn. thank you
function hasonlystrings(o) { (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' }
you're testing first value, not of them.
function hasonlystrings(o) { (var val in o) { var values = o[match]; if (typeof values != 'string') { return false; } } return true; }
Comments
Post a Comment