alert works only in web codes, not nodeJS...
alert is designed to quick output results to users.
console.log is designed to quick output debug results (to developers).
that's why you've seen primarly (annoying) alert...
You can try both console.log and alert in your browser.
alert displays a pop up box at the top of your page with the text you enter.
console.log displays what you type in the developer console (you press f12 to see the console)