Neat idea, but the closest way of which I'm aware you could come to that would be to put the vehicle objects in an array or another object, and iterate over them instead. Not needed here, though, and it wouldn't pass the challenge as you're solving a different problem.
To pass it, just nix the
add function so you're left with
vehicle3["# of weapons"] = 8;
vehicle2["# of weapons"] = 4;
vehicle1["# of weapons"] = 1;
If you add just that to the bottom of the challenge's given code, you'll pass it!