I have the following code in React:
let guest = 0; functionCup() { guest = guest 1; return{guest}’s teacup
; } export default function TeaSet() { return ( <>> ); }
My desired result is:
The first guest’s teacup Tea cup for the 2nd guest The third guest’s tea cup
However, the actual result returned is:
The second guest’s teacup, The fourth guest’s tea cup, The 6th guest’s teacup
Why is the increment of guest
2 instead of 1 as I specified?
Global state variables may not be a viable way to achieve this goal.
Based on what you mentioned in your question, you could try passing
param
ascount
.