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)
Hassan Imam
  • 21,956
  • 5
  • 41
  • 51
  • Well, split string, remove choosen word, join it again. – sinisake Dec 06 '17 at 17:18
  • Firstly I'd suggest researching before asking questions. Secondly, try [`replace()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace). Thirdly, note that `print()` isn't a standard JS function. Try `console.log()` instead – Rory McCrossan Dec 06 '17 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. – Taplar Dec 06 '17 at 17:21

0 Answers0