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

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -