Onclick works in html button but doesnt in .js file

Here is the html and .js code with onclick. If I remove onclick in html and keep it in .js it doesn’t work.