answersLogoWhite

0

If you want JavaScript to compute the square of a number (assuming that number is stored in x and the answer is stored in y) just use y = x * x.

x*x will automatically convert x to a number if it's in string format (for example: '3') and will return NaN if it's not a number. If you want to check whether or not something is a number, you can use typeof. Use an if with typeof(x) == 'number', and else return 'Please fill in a number!'

I'm not going to write the JavaScript for you, but this should help you figure it out.

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What is the serial number of counter strike extreme 1.6?

The serial number for Counter Strike Extreme 1.6 is given to those who purchase the game. It is entered to validate the game prior to playing.


Write a java that computes the value of 2?

Compute means to calculate. What do you want to "compute", if you already know it is 2? If you want to show the value:System.out.println("Your number is " + 2);Compute means to calculate. What do you want to "compute", if you already know it is 2? If you want to show the value:System.out.println("Your number is " + 2);Compute means to calculate. What do you want to "compute", if you already know it is 2? If you want to show the value:System.out.println("Your number is " + 2);Compute means to calculate. What do you want to "compute", if you already know it is 2? If you want to show the value:System.out.println("Your number is " + 2);


Fatorial of a number program in javascript?

hi darling


How do you validate a number in java script?

JavaScript is written within an HTML page (or in an external .js file but technically it's still part of the page) and adds special effects to that page. W3Schools has some really good tutorials. You can find the link in the related links. You can write JavaScript in Notepad! However most people prefer an IDE. I like Komodo Edit, personally. You can find a link for Komodo in the Related Links.


What is a number that can be entered into a cell on Excel?

Which of the following is a number that can be entered into a cell?


How do you compute fuel consumption?

number of miles driven on a tank / number of gallons to replenish that tank.


How can one learn how to program the JavaScript confirm dialog box into their code?

There are a number of ways in which one can learn how to program the JavaScript confirm dialog box into their code. One way is by reading the relevant tutorials on the website JavaScript Kit.


What does least squares mean?

Compute to the smallest fraction, reduce to the least number


What is the age of a Colt revolver serial number dT9T22?

What Colt model? Serial number given, dT9T22 does not compute.


What number was Kentucky when it entered the country?

Number fifteen.


What is a check number?

A number derived by applying a formula to a sequence of numbers which will independently validate the authenticity of an alternatively derived result.


What does least-square adjustment mean?

Compute to the smallest fraction, reduce to the least number