Working with JavaScript in Chrome
1. Create a new file called index.html and add the following html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>TSD</title>
</head>
<body>
<h1>JAVASCRIPT</h1>
<p>Tutorial</p>
</body>
<script src='date.js'></script>
</html>
2. Create a new JavaScript file
touch date.js
3. Add the following JavaScript to date.js and save it
var myDate = new Date();
console.log (myDate);
3. Check the location of date.js
pwd
/file/location/date.js
4. Launch Chrome and paste the file location of index.html into the browser
/file/location/index.html
5. From the Chrome browser
- select settings/More tools/Developer Tools
6. Check the console section for output
Result: Current date has been created