coding180 icon
Coding180
JavaScript Statements

JavaScript Statements

Home > Tutorials > JavaScript > Getting Started


JavaScript statements are commands to the browser. What these commands do is tell the browser what to do.

First look at the following code

<script type="text/javascript">
   alert("hello!");
</script>

The example alert("hello!"); is a JavaScript statement.

The end of a line is considered the end of the statement, and a semicolon is usually added at the end ";" to indicate the end of the statement.

Look at the following piece of code, there are three statements, each with ";" at the end, execute the statements in order.

<script type="text/javascript">
   document.write("I");
   document.write("love");
   document.write("JavaScript");
</script>

 

Note:  Although the semicolon ";" can also be left out, we must develop a good programming habit and remember to write a semicolon at the end of the statement.

Task - Exercise 5

Now let's enter two statement and enter some content in the web page!

1. Input on line 7:

 document.write("Hello");

2. Input on line 8:

 document.write("world");

Task Code

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sentence recognition</title>
<script type="text/javascript">

 
</script>
</head>
<body>
</body>
</html>

 


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel