I have the following in apps script:
function getQAs() {
return [
{ "Do you have any pictures ?|1 ": {"yes":2,"no":3 } },
{ "Do you have any pictures ?|2 ": {"yes":2,"no":3 } },
{ "Do you have any pictures?|3 ": {"yes":2,"no":3 } },
]
}
I'm trying to build a function that will search through the keys of The objects for a number. I'm testing with the number 1 .When I run:
function testQA() {
var qa = getQAs();
var matches = qa.keys().filter(function(row) { //ONLY CHECKED ROWS.
Logger.log(row)
return row.indexOf('1') == true;
});
Logger.log(matches);
}
I get
JS: TypeError: Cannot find function keys in object . What am I doing wrong?
keysis not a prototype method. It only exists on the 'static'Objectclass. So you would needObject.keys(qa)keys()on anarray.keys()method defined forArray(Array.prototype.keys()) ;)Array.prototype.keys()) :)