Programming Fundamentals/Introduction/JavaScript
hello.js
edit// This script displays "Hello world!"
//
// References:
// http://javascript.info/hello-world
// https://www.w3schools.com/js/js_output.asp
// http://progopedia.com/example/hello-world/114/
output("Hello world!")
function output(text) {
if (typeof document === 'object') {
document.write(text);
}
else if (typeof console === 'object') {
console.log(text);
}
else {
print(text);
}
}
Try It
editCopy and paste the code above into one of the following free online development environments or use your own JavaScript compiler / interpreter / IDE.