2

I have a rt.js file in which var k=1; is written. And i have linked it to my html file ss.html. I want to change k value to 2 and then want to print it.

The code is:

<html>
 <body>
<script type="text/javascript" src="rt.js">
 k=2;
document.write(k);
</script>
</body>
</html>

problem: Now the problem is that its supposed to print 2 but its printing 1 only. can you tell me what should i need to do?

2

1 Answer 1

2

You need to seperate your <script> tags, like so

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

and

<script>
k=2;
document.write(k);
</script>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.