benjah
September 1, 2004, 5:59pm
1
ok, let’s say i have a variable called yourPets that is defined by a prompt.
var yourPets= prompt('What pet's do you have?');
let’s say the user types “I have a dog” into the prompt box. yourPets now equals “I have a dog.”
now let’s say i want to make it so when yourPets displays, instead of “I” i want “You” to appear.
so if an alert box came up with the value (yourName) it would display “You have a dog” instead of “I have a dog.”
does that make sense? i hope so. sorry for all the questions, this is my last i swear.
system
September 1, 2004, 6:13pm
2
You should base that script on keywords… such as names like… dog, cat, bird, none… not based off a statement. That way when you have your JS read over what was typed it see’s one of those keywords and then places it in a statement that you’ve already predetermined. Like if I said “A funky dog”… what would the response be to that?
system
September 1, 2004, 6:51pm
3
yourPets = yourPets.split(“I”).join(“You”);
:thumb:
system
September 1, 2004, 7:00pm
4
many many thanks
simplistik-
to answer your question, this is how it would look:
var yourPets = prompt('What kind of pets do you have?');
yourPets = yourPets.split("I have").join(" ");
alert("You have " + yourPets + "?");
even still, that is a poor example, but i forgot what it was that i was doing where i needed to change “I” to “you”.
system
September 2, 2004, 7:58am
5
thats what the forums are here for, to help people who have questions…don’t feel guilty ask away