# My last JS question, i swear

**URL:** https://forum.kirupa.com/t/my-last-js-question-i-swear/62929
**Category:** Uncategorized
**Created:** [September 1, 2004, 5:59pm UTC](https://forum.kirupa.com/t/my-last-js-question-i-swear/62929 "2004-09-01T17:59:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![benjah](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@benjah](https://forum.kirupa.com/u/benjah)
#### Post date: [September 1, 2004, 5:59pm UTC](https://forum.kirupa.com/t/my-last-js-question-i-swear/62929/1 "2004-09-01T17:59:44Z")

</div>

ok, let’s say i have a variable called yourPets that is defined by a prompt.

```auto
 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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 1, 2004, 6:13pm UTC](https://forum.kirupa.com/t/my-last-js-question-i-swear/62929/2 "2004-09-01T18:13:27Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 1, 2004, 6:51pm UTC](https://forum.kirupa.com/t/my-last-js-question-i-swear/62929/3 "2004-09-01T18:51:12Z")

</div>

yourPets = yourPets.split(“I”).join(“You”);

:thumb:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 1, 2004, 7:00pm UTC](https://forum.kirupa.com/t/my-last-js-question-i-swear/62929/4 "2004-09-01T19:00:52Z")

</div>

many many thanks 🙂

simplistik-  
to answer your question, this is how it would look:

```auto

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”.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 2, 2004, 7:58am UTC](https://forum.kirupa.com/t/my-last-js-question-i-swear/62929/5 "2004-09-02T07:58:05Z")

</div>

> [@benjah](#):
>
> sorry for all the questions, this is my last i swear.

thats what the forums are here for, to help people who have questions…don’t feel guilty ask away 🙂
