0

I want to know how in JS/jQuery to remove parts of a string.

This is what I want it to do:

var room1 = "You see a ladder, an apple and an orange";
if(user has taken the apple) {
remove the word "apple" from the string 'room1'
print(room1)
3
  • Well, split string, remove choosen word, join it again. Commented Dec 6, 2017 at 17:18
  • Firstly I'd suggest researching before asking questions. Secondly, try replace(). Thirdly, note that print() isn't a standard JS function. Try console.log() instead Commented Dec 6, 2017 at 17:19
  • You wouldn't use jQuery for this. It has nothing to do with the DOM. Not everything must be done with jQuery. Commented Dec 6, 2017 at 17:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.