Please check the error in my html-javascript code

HTML

<!DOCTYPE html>

<html> 

<head>

	<link href = "calculator.css" rel = "stylesheet" type = "text/css"> 
	
<title>

	Calculator
	
</title>

</head>



<body id = "body">
	

	<p id = "p1"> hi there this is some sort of paragraph</p>


<script src = "calculator.js" type = "text/javascript"> 

    </script>


</body>



</html>

JAVASCRIPT CODE

var p1 = document.getElementById("p1");

p1.style.background = "green";

here, I tried giving the p1 paragraph to just check out whether my file was linked to the HTML file here i set the style property of the p1 paragraph to green but instead it did not change. please tell me why.

and one thing more -

how to use the hypen properties of css? for example the background-color property how to access it with javascript?

The CSS property is background-color. Wouldn’t it be the same in javascript?

it shows a error when i use the document.getElementById(“p1”).style.background-color = “green”;

of course it would

Found it . In javascript you camel case it backgroundColor

oh sorry i figured out the problem myself no need now