< Programming Fundamentals < Introduction

hello.js

// 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 pro world!")

function output(text) {
  if (typeof document === 'object') {
    document.write(text);
  } 
  else if (typeof console === 'object') {
    console.log(text);
  } 
  else {
    print(text);
  }
}

Try It

Copy and paste the code above into one of the following free online development environments or use your own JavaScript compiler / interpreter / IDE.

See Also

This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.