Just dipping my toes into the Javascript realm and attempting to crack this task my instructor assigned. Here's what he expects from us:
Create a function to kickstart the program. Name it start()
Inside the start() function, invoke a function named getValue()
The getValue() function should retrieve a number from the user for squaring.
Add another function inside the start() function called makeSquare()
The makeSquare() function will square the user-provided number obtained in the getValue() function.
Make sure to display the squared result within the makeSquare() function.
Here's what I managed to put together so far:
function start() {
getValue();
getSquare();
}
function getValue() {
var num = prompt("Please enter a number")
}
function getSquare() {
var squaredNum = Math.pow(num)
document.write(squaredNum)
}
start()
This activity doesn't involve any HTML tags, just grappling with getting the prompt box to work. Any thoughts on whether I'm handling variables correctly?