0

I just wonder what I am doing with console.log is wrong or not.

I have simple two files as below: index.html index.js

and when opening the index.html in chrome(c:\temp\index.html), it does not output console.log message in console tab as below. enter image description here So am I missing something?

As you can see, if you run it below code, it shows console.log properly.

function doSomething() {
    console.log("Work!");
}

doSomething();
<!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>Document</title>
</head>
<body>
    <div>Hi</div>
    <script scr='index.js'> </script>
</body>
</html>
Infinity Challenger
  • 1,090
  • 10
  • 19

2 Answers2

3

Looks like you have a typo:

<script scr='index.js'>

should be

<script src='index.js'>
TLP
  • 1,262
  • 1
  • 8
  • 20
0

function doSomething() {
    console.log("Work!");
}

doSomething();
<div>Hi</div>
<script src='index.js'> </script>

You have to change scr to src in that way it will works.

Renato Hoxha
  • 132
  • 5