HTML with JavaScript Square of numbers

how to square a number in javascript This is a topic that many people are looking for. cfiva.org is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, cfiva.org would like to introduce to you HTML with JavaScript Square of numbers. Following along are instructions in the video below:
Guys welcome what a great studio in last two videos. I have taught you you something about basic types of html from this video. We will begin our java so if you want to know more about javascript and java scripting.
Please keep watching this video until the end music yes guys so let us begin with our java scripting okay so as usual. We will go to our notepad and the powerstrips also begin with the tank similar to html so html instead of steam body okay so in body. There is a tag called a script which marks the beginning of our javascript okay so and the type of the script would be text okay slash sawa that this this is the beginning of our script.
So i will demonstrate the java scripting with the help of a program. Okay so we will write a script to print. The squares of the numbers okay so suppose a user use an input n.
That is suppose it with if we use. 5. So the output should be the squares of the first five numbers.
Okay. So we will begin with our spirit. So westwood taken variable.
Okay. So as we declare variables. In another programming language.
Like c. C. Or java with the help of the keywords those are data types.
There okay like in float. And many other in scripts. We declare the variables with the keyword where so where output okay so this is my variable and i will assign a string to this variable that is a result is okay so this is my first variable.

how to square a number in javascript-0
how to square a number in javascript-0

I will take one more variable with m. Okay so n. Is the number that i need to scan from the user so prompt sorry so prompt here is an output method okay like im gonna do that of printer force see out in c c.
Okay. So this will give an prompt to the user to given value okay so after we have scanned value. We have two special cases.
Here. The input. Prompt is not kept empty r.
Is not given to value zero. Okay. So we have to tackle both those so i will use an if condition here so where n is not equal to null and n is always greater than zero.
Okay if these both condition has met because i have used and here these both khadisha need to meet okay. So when those are made so. The controller will enter in the loop and here we have to write our logic.
So i will declare another variable named i and i will assign it to zero. So this variable. Ive been used for i will use it for my iterations.
Okay. So i will write one more message. Here is alert okay.
So the first and i equal to 1 is less than equal to n. And i plus plus ok so this is my for loop for the iteration. I with both my output in the resultant variable.

how to square a number in javascript-1
how to square a number in javascript-1

Press. And i will use a short and operator. Plus.
Here okay so n. I so as you can see ive used this plus operator. Many times in my print message so actually this plus here is not addition operator.
But it is a concatenation operator. Here so what this plus does is it concatenates the value of i with the whole message. I suppose i have used plus here okay before n.
And after n. So what this does is whatever value is stored in end is concatenated with this whole message. Okay so if nu contains a value.
5. The message that will be displayed on the screen would be the first five numbers and the squares are okay so this is how this concatenation operator hue works and this last. One is obviously for the newline character okay so well give the final that is out put.
I will close my if here as i have if i have to have else part so a lot could be input you know this is my whole script so i have to close my script tag okay. So we have opened our script eye here and we have to lose the script tag. So this is a blocked.
I close my body and htm okay. So i will save my script with like dot. Html yeah.
So the file format for both html. And the javascript remains. Same.

how to square a number in javascript-2
how to square a number in javascript-2

Because we usually write our javascript inside the same html page. Okay so i will save this ive already turned on my bam browser. Sorry wamp server.
So i will just go to my browser yeah yeah look good host you can see the dashboard of my browser. So this i have a folder called html okay so you can see these two scripts. This is our script script dot html okay yeah so this is how the prompt works okay so prompt it is asking me for the n value.
So i will give you some called six. So just press ok. So that then the next message that we gave using the alert that is given here okay.
This is the alert box it says the first six numbers and the squares are okay so you get this output. Okay so the result is 1 and 1 into. 1.
Is 1 two twos are four three threes are nine. Okay so these are the square of the first six number right so our script is working accordingly and so this is how you can write a script for your html. This scripts can be furtherly used in our forms or retrying.
The data from the user okay so in next video. I will show you the css okay the css is again called is a styling styling sheet okay so in previous videos. We have applied the styles using style tag so css is a better version of applying the styles to the html pages.
So we will discuss about css in next video and we will also start our form from the discretion of the forum in upcoming videos. So please subscribe. You have a link over the video and you can also check out our other segment.
Which is based on c c. And java and which can help you to build better logic of programming. So guys please keep watching our videos.
Thank you .

how to square a number in javascript-3
how to square a number in javascript-3

Thank you for watching all the articles on the topic HTML with JavaScript Square of numbers. All shares of cfiva.org are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.

Leave a Comment

Your email address will not be published. Required fields are marked *