Javascript beginning

Why is my javascript code not reflecting on the chrome? The code is -

<!DOCTYPE html>
<html>
<head>
	<title>
		<script type="text/javascript">
			var name="Sachin";
			console.log(name);
			
		</script>
	</title>
</head>
<body>
</body>
</html>

Hi @soumyadash0309,

Your JavaScript code is inside the title tag that is incorrect. Please place it after title tag and it will work -
Check the code below -

<!DOCTYPE html>
<html>
<head>
    <title>
        
    </title>
    <script type="text/javascript">
            var name="Sachin";
            console.log(name);
            
    </script>
</head>
<body>
</body>
</html>

Do let me know in case you need any other information.

Yes sir thanks a lot for clearing the doubt

1 Like