Edit question how do i test my javascript function such as this one function props(list, propertyName){ var result=[]; for(var x in list) { result.push(list[x][propertyName]); } return result; } the instuctions for this were as follows props( list, propertyName ) This function takes a list of elements and a propertyName string as input. The function returns a list that is generated by obtaining the property-named value of an input element. If a list element doesn't have a property of the specified name, then its value is given as undefined. Examples var testing = [{ a:3, b:‘Cat’, c:true }, 13, { a:12, b:‘Hat’, c:false }, { cat:3, hat:‘3’, rat:false } ]; props( testing, ‘b’ ) => [ ‘Cat’, undefined, ‘Hat’, undefined ] props( testing, ‘a’ ) => [3, undefined, 12, undefined ] props( testing, ‘cat’ ) => [undefined, undefined, undefined, 3 ] if there is an online ide that would work or anything would help! i just need to know how to test things like this for an assignment thank you!! showing it working would be amazing as well thank yoU!!
how do i test my javascript function such as this one
function props(list, propertyName){
var result=[];
for(var x in list) {
result.push(list[x][propertyName]);
}
return result;
}
the instuctions for this were as follows
props( list, propertyName )
This function takes a list of elements and a propertyName string as input. The function returns a list that is generated by obtaining the property-named value of an input element. If a list element doesn't have a property of the specified name, then its value is given as undefined.
Examples
- var testing = [{ a:3, b:‘Cat’, c:true }, 13, { a:12, b:‘Hat’, c:false }, { cat:3, hat:‘3’, rat:false } ];
- props( testing, ‘b’ ) => [ ‘Cat’, undefined, ‘Hat’, undefined ]
- props( testing, ‘a’ ) => [3, undefined, 12, undefined ]
- props( testing, ‘cat’ ) => [undefined, undefined, undefined, 3 ]
if there is an online ide that would work or anything would help! i just need to know how to test things like this for an assignment thank you!!
showing it working would be amazing as well thank yoU!!

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









