convert example to javascript