WeightWatchers interview question

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