How to access object element key from a variable?

Good day,

There is an object with the same keys but with different suffixes:

var ob = {
 name_1 : "www", name_2:"yyy", name_3:"zzz"
};
var str = 'name_' + getSuff();
var res = ob.str;


The last line throws an error on non-existent element. Tell me - how this point can be implemented correctly?
July 2nd 19 at 17:47
1 answer
July 2nd 19 at 17:49
Solution
ob[str]
And thank you! - dudley_Ri commented on July 2nd 19 at 17:52

Find more questions by tags JavaScript