How to increment a value in an object with Node.js

1 Answer

0 votes
const obj = {
  nodejs: 1,
  c: 99,
  python: 88,
};
 
obj.nodejs = obj.nodejs + 1 || 1;
 
console.log(obj);
    
    
    
    
    
/*
run:
    
{ nodejs: 2, c: 99, python: 88 }
    
*/

 



answered May 11, 2022 by avibootz

Related questions

1 answer 200 views
1 answer 222 views
1 answer 186 views
186 views asked May 3, 2022 by avibootz
1 answer 224 views
1 answer 274 views
1 answer 215 views
...