0% found this document useful (0 votes)
50 views20 pages

IT 2022 Paper Solution

The document contains the solutions to various questions related to networking protocols, IP addressing, proxy servers, JavaScript functions, differences between forums and blogs, and static vs dynamic routing. The questions cover topics like explaining the ipconfig and tracert commands, writing the network address, broadcast address, valid host addresses and subnet mask for a given IP, describing what a proxy server is and two advantages, explaining the setTimeout() and setInterval() functions in JavaScript with examples, listing four differences between forums and blogs, providing the value of key "a" in a JSON object, writing a JavaScript program to greet a user based on current time, and explaining the difference between static and dynamic routing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views20 pages

IT 2022 Paper Solution

The document contains the solutions to various questions related to networking protocols, IP addressing, proxy servers, JavaScript functions, differences between forums and blogs, and static vs dynamic routing. The questions cover topics like explaining the ipconfig and tracert commands, writing the network address, broadcast address, valid host addresses and subnet mask for a given IP, describing what a proxy server is and two advantages, explaining the setTimeout() and setInterval() functions in JavaScript with examples, listing four differences between forums and blogs, providing the value of key "a" in a JSON object, writing a JavaScript program to greet a user based on current time, and explaining the difference between static and dynamic routing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Unique Paper Code : 32341501

Name of the Paper : Internet Technologies


Name of the Course : B.Sc. (H) Computer Science

Solution
SECTION A

a. Explain the following Networking Protocols with a suitable example. ( 2+2) =4

ipconfig– It is used to displays all current TCP/IP network configuration values and
refreshes Dynamic Host Configuration Protocol (DHCP) and Domain Name System
(DNS) settings. Used without parameters, ipconfig displays Internet Protocol version
4 (IPv4) and IPv6 addresses, subnet mask, and default gateway for all adapters.

tracert– The TRACERT diagnostic utility determines the route to a destination by


sending Internet Control Message Protocol (ICMP) echo packets to the destination. In
these packets, TRACERT uses varying IP Time-To-Live (TTL) values.
b. Write the network address, broadcast address, valid host addresses and subnet
mask for the IP address. 198.22.45.173/26. ( 1 +1+1+1)=4

Network Address = 198.22.45.128/26


Broadcast address = 198.22.45.191
Valid host address = 198.22.45.129 to 198.22.45.190
Subnet mask = 255.255.255.192 (26 1’s)

c. What do you understand by Proxy Server? Write ANY TWO advantages of


using it. (2+2)=4

A proxy server acts as a gateway between you and the internet. It’s an intermediary
server separating end users from the websites they browse. Proxy servers provide
varying levels of functionality, security, and privacy depending on your use case,
needs, or company policy.

ANY TWO of the following:


 Bandwidth savings and improved speeds
 Privacy benefits
 Improved security
 Get access to blocked resources
 To control internet usage of employees and children

d. Explain setTimeout() and setInterval() functions with examples. (2+2)=4

setTimeout() - The setTimeout() method executes a block of code after the specified
time. The method executes the code only once.
The commonly used syntax of JavaScript setTimeout is:
setTimeout(function, milliseconds);

setInterval() - The setInterval() method repeats a block of code at every given timing
event.
The commonly used syntax of JavaScript setInterval is:
setInterval(function, milliseconds);
Any example like given below:
<!DOCTYPEhtml>
<htmllang="en">

<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Use of setinterval and settimeout</title>
<style>
.text {
text-align: center;
}
</style>
</head>

<body>
<h1class="text">SET INTERVAL EXAMPLE</h1>
<divid="background"style="height: 200px;"></div>
<h1class="text">SET TIME OUT EXAMPLE</h1>

<labelfor="myp">NEW TEXT APPEARS HERE</label>


<pclass="text"id="myp"></p>
<script>
vardoc = document.getElementById("background");
varcolor = ["black", "blue", "brown", "green", "red", "yellow"];
vari = 0;
functionchange() {
doc.style.backgroundColor = color[i];
i++;

if (i>color.length - 1) {
i = 0;
}
}
setInterval(change, 2000);

constpdisplay = document.getElementById("myp");

functionmyMessage() {
pdisplay.innerHTML = "Now the text appears";
console.log("message appeared");
}
setTimeout(myMessage, 15000);
</script>
</body>

</html>
e. Write ANY FOUR differences between Forum and Blog. ( 1+1+1+ 1+ 1) =4

Any four of the following.

Forum Blog
Forum is User Generated Content. Blog is an Author Generated Content.
Members participate in the discussion to share Author share views and ideas on the
views and ideas. blog topic.
Apart from comments, interaction
The discussions are more real-time provided
with the blogger can have a lag
member content doesn’t need to pass the
depending on the availability of the
moderation queue.
blogger.
For questions, one has to ask the
Can take the form of question and answers. blogger, and he may answer readers’
questions.
Only the author (or in case of a multi-
Any user can ask a question and other experts in the
author blog – authors) responds to
area can answer the question,
readers’ questions.
The responses in the forum may not be from an As a blog author, one tends to reply to
expert in the field and often is the case. questions with thorough research.
Blog authors who get a lot of
Forum answers aren’t from an authority in the
questions from readers are considered
domain.
an authority in the subject matter.
Bloggers tend to build the trust of the
One can’t trust the worthiness of the forum replies. readers and share views and ideas that
are trustworthy.
Blogs are one-to-many discussion
Forums are a many-to-many discussion platform.
platforms, even if you consider guest
Any member can create a discussion, and others
article contribution. Readers express
can reply.
views on the article in comments only.
Forums are tough to manage. One may need to
Blogs, on the other hand, are much
monitor for spam, content, reply to topics to make it
easier to manage.
look active, etc.
Blogs need a lot of time on research
Forums are much easier to generate content. before an author can write about the
topic.
Forums are tough to get rolling. Members will be Blogs, on the other hand, are much
interested in creating discussions only when they easier to start rolling. Even if you
see an active community. In short, members will don’t have an active reader-base, all
create content when they see the others getting their one needs is a motivation to keep
reply or having fruitful discussions. blogging.
Forums contain user-generated queries, which
Blog authors need to answer readers’
means there are chances others will have the same
queries and generate the blog archives
questions. Archives will serve the purpose of SEO
to be able to rank well in Google.
traffic.
Google doesn’t make forum discussion as Blog authors have an edge when it
authoritative content. The trustworthiness of the comes to the authoritativeness and
content is also questionable. trustworthiness of the content.
Forums support social media features like
membership, private messages, visitor messages,
Blog lack social media features.
friends and followers, social groups, member
birthdays, etc
You always need to monitor the forum for
You don’t always need to be blogging.
moderation.
For a blog, it is the blogger who starts
In forums, members are all equal. Anyone can start
the topic, and discussion may continue
a discussion on a topic.
in comments.

f. JSON object. Value of a is ________________ . 2

g. Write a JavaScript program to Greet the user based on the current time.
3
<html>

<body>
<script>
varwelcome;
vardate = newDate();
varhour = date.getHours();
varminute = date.getMinutes();
varsecond = date.getSeconds();
if (minute<10) {
minute = "0" + minute;
}
if (second<10) {
second = "0" + second;
}
if (hour<12) {
welcome = "good morning";
} elseif (hour<17) {
welcome = "good afternoon";
} else {
welcome = "good evening";
}
document.write("<h2>" + "<font color='red'>" + welcome + "</font>" + "
welcome to our website");
document.write("<br>" + hour + ":" + minute + ":" + second);
</script>
</body>

</html>

h. Explain the difference between Static routing and Dynamic Routing. 3


Any 3 of the following.

Static Routing Dynamic Routing

In static routing, user-defined routes are In dynamic routing, routes are updated as per
used in the routing table. the changes in network.

No complex algorithm used to figure Dynamic routing employs complex algorithms


out the shortest path. to find the shortest routes.

Static routing provides higher security. Dynamic routing is less secure.

Static routing is a manual process. Dynamic routing is an automatic process.

Static routing is used in smaller Dynamic routing is implemented in large


networks. networks.

Static routing may not follow any Dynamic routing follows protocols like BGP,
specific protocol. RIP and EIGRP.

Static routing does not require any Dynamic routing requires additional resources
additional resources. like memory, bandwidth etc.

i. You need to subnet a network that has 5 subnets, each with at least 16 hosts. Which classful of
the following subnet masks are valid in the above situation?
2
i. 255.255.255.192 -Valid
ii. 255.255.255.224
iii. 255.255.255.240
iv. 255.255.255.248

Subnets are represented by 1 and thus require at least 3 one’s in subnet mask for 5
subnets. Similarly 16 hosts needed so at least 4 zero’s are required in subnet mask.

For 255.255.255.192, the binary equivalent of 192 is 11000000. INVALID as number


of one’s are not sufficient.
For 255.255.255.224, the binary equivalent of 224 is 11100000. VALID as number of
one’s and zero’s are sufficient.
For 255.255.255.240, the binary equivalent of 240 is 11110000. INVALID as number
of zero’s are not sufficient (we can have 16 hosts but first and last address are
reserved so only 14 left with 4 zeros thus 16 hosts are not possible).

For 255.255.255.248, the binary equivalent of 248 is 11111000. INVALID as number


of zero’s are not sufficient.

j. What are cookies? Explain Sessions in Cookie. (1+2)=3


A cookie is an item of data that a web server saves to your computer’s hard disk via a
web browser. It can contain almost any alphanumeric information (as long as it’s under 4
KB) and can be retrieved from your computer and returned to the server. Common uses
include session tracking, maintaining data across multiple visits, holding shopping cart
contents, storing login details, and more.
Sessions are the groups of variables that are stored on the server but relate only to the
current user. To ensure that the right variables are applied to the right users, the
programming language saves a cookie in the users’ web browsers to uniquely identify
them.

Various methods can be applied for implementing sessions in cookies such as:
 Starting a Session
 Ending a Session
 Setting a Timeout
 Session Security

k. Define JSON.stringify() and JSON.parse() functions. (1+1)=2

To transfer data from one program to another or from the server to the client-side, it is
best to convert the JSON object back to a JSON string. For these conversions,
JavaScript provides two functions JSON.parse() &JSON.stringify().

JSON.stringify():
The JSON.stringify() method converts a JavaScript value to a JSON string, optionally
replacing values if a replacer function is specified or optionally including only the
specified properties if a replacer array is specified.
Syntax:
JSON.stringify(value)
JSON.stringify(value, replacer)
JSON.stringify(value, replacer, space)

Value: The value to convert to a JSON string.


Replacer: A function that alters the behavior of the stringification process, or an array of strings or numbers
naming properties of value that should be included in the output.
Space: A string or number that's used to insert white space (including indentation, line break characters, etc.)
into the output JSON string for readability purposes.

JSON.parse():
The JSON.parse() method parses a JSON string, constructing the JavaScript value or
object described by the string. An optional reviver function can be provided to
perform a transformation on the resulting object before it is returned.
Syntax:
JSON.parse(text)
JSON.parse(text, reviver)

Text: The string to parse as JSON.


Reviewer: This prescribes how each value originally produced by parsing is transformed before being returned

SECTION B

Answer 2:

a) Crawling: Crawler" (sometimes also called a "robot" or "spider") is a generic term for any
program that is used to automatically discover and scan websites by following links from one
webpage to another. Crawling can take anywhere from a few days to a few weeks.

b) Indexing: Web indexing, or internet indexing, comprises methods for indexing the contents
of a website or of the Internet as a whole. Search engines usually use keywords and
metadata to provide a more useful vocabulary for Internet or onsite searching. For example,
With the increase in the number of periodicals that have articles online, web indexing is also
becoming important for periodical websites.Google can index the content of most types of
pages and files. The most common file types we index include:
 Adobe Portable Document Format (.pdf)
 Adobe PostScript (.ps)
 Google Earth (.kml, .kmz) and many more.

c) Internet Protocols: Internet Protocol is the set of rules required to be followed for sending
data packets from source to destination across different network boundaries. HTTP stands
for Hypertext Transfer Protocol, and is the foundation of data communication for the World
Wide Web, where hypertext documents include hyperlinks to other resources that the user
can easily access.Simple Mail Transfer Protocol (SMTP) is a text-based protocol usually used
by two mail servers to exchange e-mail. File Transfer Protocol (FTP) allows user to transfer
files from one host to another.

d) Internet VS Intranet:

Internet:
Internet is a public network of computers connected simultaneously and can be accessed by
any one and anywhere.
Intranet:
Intranet is the type of internet that is used privately. There are limited users connected to
Intranet and is usually used within an organization.

e) Domain Name Server: When you type an address into a browser and hit Enter, you expect
to arrive at the intended website. Without the Domain Name System (DNS), that wouldn't
happen. Whether simple or very complex, networks worldwide rely on the DNS to connect
client and target.DNS has a number of capabilities, but one of its most fundamental is
translating an easy-to-remember site name into an Internet address (IP).

Answer 3:
Given list

John

Merry

Martian

Ketty

i) Add Matt to the beginning of the given list

$("ul").prepend("<li>Matt</li>");

Add Damon to the end of the given list

$("ul").append("<li>Damon</li>");

ii) Add surnames to the given list

var surname=["Jonas","Mathew","Lane","steven","lane","gadot","Hartley"];

$(document).ready(function(){

$("button").click(function(){

i=0;

$("li").each(function(){

$(this).append(surname[i]);

i++;

});

});
});

iii) Add a class MyName to each of the item list

$("li").addClass("MyName");

Iv) Give a background color to the list

$("li").each(function(){

$(this).css("background-color","#333333");

});

v) Clicking on a list item should change its background color

$("ul").click(function(){

$("li").css("background-color","blue");

});

Answer 4:

a) The original intention of NAT was to slow the depletion of available IP address space
by allowing many private IP addresses to be represented by some smaller number of
public IP addresses. Network Address Translation allows a single device, such as a
router, to act as an agent between the Internet (or "public network") and a local (or
"private") network.

Any example of NAT

b) Data can be formatted using JSON. It looks very similar to object literal syntax, but it
is not an object. JSON data looks like the object literal notation, however, it is just
plain text data (not an object).JSON object holds key/value pair. Each key is
represented as a string in JSON and value can be of any type. The keys and values are
separated by colon. Each key/value pair is separated by comma.

{
"name":"Rahul",
"roll number":1001,
"course":"BSC",
"mobile":210021,
"email":"abc@ced.com"
};

Answer 5

Pagination:
Bootstrap pagination is a component used to indicate the existence of a series of related content
across multiple pages and enables navigation across them.

For example:

<nav aria-label="Page navigation example">


<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</nav>

List Groups:

List Groups are used to display a series of content. We can modify them to support any content as
per our needs. The use of List-Groups is just to display a series or list of content in an organized way.
<p>To do list</p>

<ul class="list-group">
<li class="list-group-item">study</li>
<li class="list-group-item">pay bills</li>
<li class="list-group-item">call mom</li>
<li class="list-group-item">drop an email</li>
</ul>

Panels:

A panel in bootstrap is a bordered box with some padding around its content:

Panels are created with the .panel class, and content inside the panel has a .panel-body class:

<div class="container">

<h2>Basic Panel</h2>

<div class="panel panel-default">

<div class="panel-body">A Basic Panel</div>

</div>

</div>
Navbars:

A navigation bar is a navigation header that is placed at the top of the page. With Bootstrap, a
navigation bar can extend or collapse, depending on the screen size. A standard navigation bar is
created with <nav class="navbar navbar-default">.

For example:

<nav class="navbar navbar-default">


<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">WebSiteName</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Page 3</a></li>
</ul>
</div>
</nav>
Dropdowns:

A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined
list:

For Example:

<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-
toggle="dropdown">Dropdown Example
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#">HTML</a></li>
<li><a href="#">CSS</a></li>
<li><a href="#">JavaScript</a></li>
</ul>
</div>

(b)
Create Server.js file:

// server.js
const express = require("express");

const app = express();

app.get('/', (req, res)=>{


res.send("Hello, world!");
});

app.listen(8000, ()=>{
console.log("Server running on port 4000");
});

Register.html:

<!--register.html-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login and register form with Node.js, Express.js and MySQL</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<h2>Login and register form with Node.js, Express.js and MySQL</h2>
<h3>Register form</h3>
<form action="/register" method="POST">
<div class="form-group mb-3">
<label>First name</label>
<input type="text" class="form-control" placeholder="First name"
name="firstName">
</div>
<div class="form-group mb-3">
<label>Last name</label>
<input type="text" class="form-control" placeholder="Last name"
name="lastName">
</div>
<div class="form-group mb-3">
<label>Username</label>
<input type="text" class="form-control" placeholder="Username"
name="userName">
</div>
<div class="form-group mb-3">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password"
name="password">
</div>
<div class="d-grid mt-3">
<button type="submit" class="btn btn-primary form-control">Submit</button>
</div>
</form>
</div>
</body>
</html>

Login.html:

<!--login.html-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login and register form with Node.js, Express.js and MySQL</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<h2>Login and register form with Node.js, Express.js and MySQL</h2>
<h3>Login form</h3>
<form action="/dashboard" method="POST">
<div class="form-group mb-3">
<label>Username</label>
<input type="text" class="form-control" placeholder="Username"
name="userName">
</div>
<div class="form-group mb-3">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password"
name="password">
</div>
<div class="d-grid mt-3">
<button type="submit" class="btn btn-primary form-control">Submit</button>
</div>
</form>
</div>
</body>
</html>

SQL form:

const express = require('express');


const cookieParser = require("cookie-parser");
const sessions = require('express-session');
const http = require('http');
var parseUrl = require('body-parser');
const app = express();

var mysql = require('mysql');

let encodeUrl = parseUrl.urlencoded({ extended: false });

//session middleware
app.use(sessions({
secret: "thisismysecrctekey",
saveUninitialized:true,
cookie: { maxAge: 1000 * 60 * 60 * 24 }, // 24 hours
resave: false
}));

app.use(cookieParser());

var con = mysql.createConnection({


host: "localhost",
user: "root", // my username
password: "123456789", // my password
database: "myform"
});

app.get('/', (req, res) => {


res.sendFile(__dirname + '/register.html');
})

app.post('/register', encodeUrl, (req, res) => {


var firstName = req.body.firstName;
var lastName = req.body.lastName;
var userName = req.body.userName;
var password = req.body.password;

con.connect(function(err) {
if (err){
console.log(err);
};
// checking user already registered or no
con.query(`SELECT * FROM users WHERE username = '${userName}' AND
password = '${password}'`, function(err, result){
if(err){
console.log(err);
};
if(Object.keys(result).length > 0){
res.sendFile(__dirname + '/failReg.html');
}else{
//creating user page in userPage function
function userPage(){
// We create a session for the dashboard (user page) page and save the user data to
this session:
req.session.user = {
firstname: firstName,
lastname: lastName,
username: userName,
password: password
};

res.send(`
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login and register form with Node.js, Express.js and MySQL</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<h3>Hi, ${req.session.user.firstname} ${req.session.user.lastname}</h3>
<a href="/">Log out</a>
</div>
</body>
</html>
`);
}
// inserting new user data
var sql = `INSERT INTO users (firstname, lastname, username, password)
VALUES ('${firstName}', '${lastName}', '${userName}', '${password}')`;
con.query(sql, function (err, result) {
if (err){
console.log(err);
}else{
// using userPage function for creating user page
userPage();
};
});

});
});

});
app.listen(8000, ()=>{
console.log("Server running on port 4000");
});

Answer 6 A: A HTML program which implements radio button functionality. Step marks
may be given.

B. A HTML program which implements form and also log the inputted value using
JSON and AJAX concepts.

Answer 7. A

What are the various components of an email? Define the mail message format of
SMTP. Also discuss the functionalities of any TWO mail access protocols.

Simple Mail Transfer Protocol (SMTP) is a text-based protocol usually used by two mail
servers to exchange e-mail. Users can then retrieve e-mail from the servers via mail clients
such as Outlook, Eudora, or Pine. SMTP is composed of four key components:

a. Local user or client-end utility known as the mail user agent (MUA)
b. Server known as mail submission agent (MSA)
c. Mail transfer agent (MTA)
d. Mail delivery agent (MDA)

Mail message format

smtp: protocol for exchanging email msgs


RFC 822: standard for text message format:

 header lines, e.g.,


o To:
o From:
o Subject:
different from smtp commands!

 body
o the “message”, ASCII characters only

header
body
blank
line
OR

(student can define a general mail format)

TWO mail access protocols are:

1. POP3
Post Office Protocol, version 3 (POP3) is simple and limited in functionality. Theclient
POP3 software is installed on the recipient computer; the server POP3 softwareis
installed on the mail server.
Mail access starts with the client when the user needs to download e-mail from
themailbox on the mail server. The client opens a connection to the server on TCP port.It
then sends its user name and password to access the mailbox. The user can then listand
retrieve the mail messages, one by one.

2. IMAP3
Another mail access protocol is Internet Mail Access Protocol, version 4 (IMAP4).IMAP4 is
similar to POP3, but it has more features; IMAP4 is more powerful and morecomplex.IMAP4
provides the following extra functions:
 A user can check the e-mail header prior to downloading.
 A user can search the contents of the e-mail for a specific string of characters priorto
downloading.
 A user can partially download e-mail. This is especially useful if bandwidth is
limitedand the e-mail contains multimedia with high bandwidth requirements.
 A user can create, delete, or rename mailboxes on the mail server.
 A user can create a hierarchy of mailboxes in a folder for e-mail storage.

Answer 7. B

What are event listeners? Why it is used. Explain it with example.

An event is an important part of JavaScript.A web page respond according to an event


occurred. Some events are user generated and some are generated by API’s. An event listener
is a procedure in JavaScript that waits for an event to occur. The simple example of an event
is a user clicking the mouse or pressing a key on the keyboard.
The addEventListener() is an inbuilt function in JavaScript which takes the event to listen for
and a second argument to be called whenever the described event gets fired. Any number of
event handlers can be added to a single element without overwriting existing event handlers.

Syntax:
element.addEventListener(event, listener, useCapture);

event : event can be any valid JavaScript event.


listener(handler function) : It can be a JavaScript function which respond to the event occur.
useCapture: It is an optional parameter used to control event propagation.

ANY EXAMPLE LIKE THE FOLLOWING:

<!DOCTYPEhtml>
<html>

<body>
<buttonid="try">Click here to show text</button>
<h1id="text"></h1>
<script>
document.getElementById("try").addEventListener("click", function(){
document.getElementById("text").innerText = "Now the text appears";
});
</script>
</body>
</html>

You might also like