Project 1 - HELP PLZ

Ok, so, I presented an idea to my counselor who encouraged me to go along with it and maybe even carry it with me to keep working and updating it as my study plan progresses; that sounded like a great idea to me.

What I wanted to attempt was to make a website that emulates rocket pool basically. My counselor suggesting doing the best equivalent I could using JavaScript. So basically I wanted to show what I have so far and let everyone know specifically what I THINK my issues are what I actually want/need to get accomplished. Thank you in advance to anyone/everyone for helping.

html
head

script src=“https://ajax.googleapis.com/ajax/libs/jquery.min.js”></script

script
function greet(){
alert(‘Your staked assets will now accrue interest until such time as you withdraw them or there are no more rewards to earn!’);
}
/script>
/head>

body>

form id=“demo” onsubmit=“greet(); return false;”>
input id = “name” placeholder=“Asset” type=“text”/>
input type =“submit”/>
/form>

script>

const accrueInterest = 1000;
let asset = 0;
while (accrueInterest){
console.log(There are ${asset} gaining interest.)
asset++;
if (asset === 1000){
console.log(“There are no more rewards to earn!”);
break;
}
}

/script>

/body>
/html>

A. When the user enters a number into the Asset box and clicks submit, the number stays in the box, as if it wasn’t submitted.
B. Another issue I’m having is that my while loop starts running and printing to the console before any input has been submitted by the user.
C. Lastly, I need a way to store the input from the user and call it back later to show the user how it has changed.

1 Like

Hey @Vote3rdParty, hope you are good.

Now could you please copy/paste your code inside the preformatted text button? So we can review it properly to help you.

You can use the “Preformatted Text” Button to encapsulate any kind of code you want to show.


function formatText(){

let words = “I’m a preformatted Text box, Please use me wisely!”

}

prefromatted_text-animated

Carlos Z.

1 Like

Hey @Vote3rdParty, hope you are good.

Now could you please copy/paste your code inside the preformatted text button? So we can review it properly to help you.

You can use the “Preformatted Text” Button to encapsulate any kind of code you want to show.


function formatText(){

let words = “I’m a preformatted Text box, Please use me wisely!”

}

prefromatted_text-animated

Carlos Z.

<html>
<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery.min.js"></script>

<script>
function greet(){
  alert('Your staked assets will now accrue interest until such time as you withdraw them or there are no more rewards to earn!');
}
</script>
</head>


<body>


<form id="demo" onsubmit="greet(); return false;">
  <input id = "name" placeholder="Asset" type="text"/>
  <input type ="submit"/>
</form>

<script>

const accrueInterest = 1000;
let asset = 0;
while (accrueInterest){
  console.log(`There are ${asset} gaining interest.`)
  asset++;
  if (asset === 1000){
    console.log("There are no more rewards to earn!");
    break;
  }
}


</script>

</body>
</html>

Thank you so much for your time and consideration.

1 Like

OK, what is exactly the issue?, you should not have a script tag with a function inside the head tag, all your custom JS code should be inside 1 script tag that is contained on the body tag.

I mean, your greet() function should be inside the script tag on body tag, not in the head tag.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Thank you very much,

So other than my code not being in the right order, my problems were:

  1. That I don’t know how to store the value that the user inputs such that the value will then go through my loop to accrue interest.
  2. I want to be able to take this stored value which has gone through my loop to accrue interest and give it back to the user upon request via the press of a button.