d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Very Basic Java Question
Add Reply New Topic New Poll
Member
Posts: 10,803
Joined: Apr 5 2010
Gold: 20.00
Oct 5 2015 04:47pm
this is the code using jedit very basic like I said

var firstFlower;
var secondFlower;
var switchUp;

firstFlower = prompt("pick a flower");
secondFlower = prompt("pick another flower");

document.write("flower one: " + firstFlower);
document.write("<br />");
document.write("flower two: " + secondFlower);


and this is the sample output

Strings as entered:
variableOne: Rose
variableTwo: Daisy

Switched strings:
variableOne: Daisy
variableTwo: Rose

how do you switch the variables around without writing the obvious document.write
we can use 3 varriables that's it
Member
Posts: 29,375
Joined: Mar 27 2008
Gold: 504.69
Oct 5 2015 05:11pm
A selection statement within a loop. Use the third variable as a counter.
Member
Posts: 10,803
Joined: Apr 5 2010
Gold: 20.00
Oct 5 2015 05:29pm
Quote (ROM @ Oct 5 2015 06:11pm)
A selection statement within a loop. Use the third variable as a counter.


care to type it out this is the last thing I have to do for tonight lol I looked at his notes nothing couldn't fine an example
Member
Posts: 29,375
Joined: Mar 27 2008
Gold: 504.69
Oct 5 2015 05:37pm
Quote (jsbb @ Oct 5 2015 07:29pm)
care to type it out this is the last thing I have to do for tonight lol I looked at his notes nothing couldn't fine an example


Int switchUp;

For (switchUp = 0; switchUp < 2; switchUp++){
If (switchUp==1){
Print it one way
}
Else{
Print the other way
}
}

This post was edited by ROM on Oct 5 2015 05:39pm
Member
Posts: 10,803
Joined: Apr 5 2010
Gold: 20.00
Oct 5 2015 06:21pm
Quote (ROM @ Oct 5 2015 06:37pm)
Int switchUp;

For (switchUp = 0; switchUp < 2; switchUp++){
If (switchUp==1){
Print it one way
}
Else{
Print the other way
}
}


no I have no idea what that shit is well its a if statement but we just started those

switchUp = firstFlower;

firstFlower = secondFlower;

secondFlower = switchUp;

if you post this after the initial 2 document.writes then do an adition 2 document.writes using the same varriables it works

that is not basic lol

This post was edited by jsbb on Oct 5 2015 06:26pm
Member
Posts: 29,375
Joined: Mar 27 2008
Gold: 504.69
Oct 5 2015 06:29pm
Quote (jsbb @ Oct 5 2015 08:21pm)
no I have no idea what that shit is well its a if statement but we just started those

switchUp = firstFlower;

firstFlower = secondFlower;

secondFlower = switchUp;

if you post this after the initial 2 document.writes then do an adition 2 document.writes using the same varriables it works

that is not basic lol


Derp even more simple then I went.
You are literally just learning how assignment works.

Member
Posts: 10,803
Joined: Apr 5 2010
Gold: 20.00
Oct 5 2015 06:32pm
Quote (ROM @ Oct 5 2015 07:29pm)
Derp even more simple then I went.
You are literally just learning how assignment works.


no shit lol im taking into to java scrip
and intro to html
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll