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 109 views
1 answer 123 views
1 answer 123 views
1 answer 118 views
1 answer 106 views
1 answer 114 views
...