You can
put this solution on YOUR website!if you work backwards it is easier to figure out the answer.
at the end he was left with 8 jellybeans.
before this he ate two thirds - this tells us that 8 equals one third, therefore he previosly had 24 jellybeans. (8*3=24)
if he gave one third to a friend then the remaining amount must be two thirds, therefore he began with 36 jellybeans. (24/2=12 12*3=36)