Domanda di colloquio di WeightWatchers

Without using a particular native Javascript function, rewrite that function using plain Javascript.