You can interact with JavaScript by using the console in our browser.
How to access the console page by right clicking inspect
You can write Java Script commands directly in this console.
Or you can write Java Script in a tag called script before the body tag
Example :
<!DOCTYPE html>
<html lang="en''>
<head>
<meta charset="UTF-8">
<title>Javascript</title>
</head>
<body>
<h1>Hello World</h1>
<script src ="latihan.js''><script>
</body>
</html>
How to write in Java Scripts
document.write('............');
document.write('i love you');document.write('i miss u)
When you write Java Script code you will definitely write more than one.
And so that we don't get confused, we need a name komentar.
How to write komentar ?
You can write komentar by write //
And if you write // in front of your text. Then your writing will not be read.
Example :
//document.write('i love you sayang')
document.write(' i miss U sayang')
From the example above that i colored green, the text does't appear in the browser because it has been marked.
But the // sign only works if the writing is only 1 line.
And if you want to write a komentar more than 1 you can use the /* ........*/sign.
Example :
/*document.write('You want to eat ?') ;
document.write('No i don't')
*/
And what i have written in blue we not be visible because is it marked /*......*/
Let name = 'Anisa Wulandari', umur=23, Alamat= 'Klaten'
document.write(alamat);
what will appear is klaten. because we are calling the Adress. And the address in the let name Klaten.
If we want to write a variable whose contents cannot change, we can use cons.
And if we want to write a variable whose contents can change we can use let.