英语吧有些文章不一定是为了上首页投稿简友广场

JavaScript Basic: Prompt & C

2019-05-30  本文已影响14人  此之木

Today the course assigned a simple JavaScript exercise:

Here is my steps:

Step One: Create a HTML page and link to the JavaScript File

I create a simple HTML page and give a title “JS Stalker Exercise”. Then, I link the HTML page to a new JS file named “stalker.js”.

Step Two: Enter variable data in the JS file

In the JS file, I start to write three prompt messages which are asking for user’s first name, last name and age.

In order to print out user’s full name and age in separate sentences, I set two console.log message. The only thing we need to pay attention is the spacing between each word. 

The print sentence has one small space between each word : Your full name is X X. Therefore, in the console.log, we need to set the right space for each word.

Step Three: Test the result

When I open the page, it asks me three pop up questions in orders:

After I answer each questions, I can see the print sentences in the console.

上一篇 下一篇

猜你喜欢

热点阅读