JS sample seems incorrect. 

x should be the input of the function