title: How to edit a characters in a string, and remove characters that editing conditions apply to
body: <p>I'm trying to take in a number from a user, display the number as a range,and then replace instances of the number 3 with a string, instances of the number 2 with a string, and instances of the number 1 with a string. If the function detects a 3, I want it to replace it with the string, remove the instance of 3, and ignore the conditions for replacing 2 &amp; 1. The same goes for when it sees a 2 (but not a 2). </p>
  
  <p>I have the function taking in the number from the user, converting it to a string, and then displaying it as a range using a for loop.</p>
  
  <p>In the for loop I use .includes to look for a '3.' When it sees one it is pushing the string "I'm sorry Dave, I can't do that" to the same list that displays the range. </p>
  
  <p>I've tried an if/else if statement to have the loop ignore the conditions for 2 and 1 if it first sees a three, however it is applying all conditions to all instances of 3,2, or 1.</p>
  
  <pre><code>function numTranslate(inputNumber){
    var numList = [];
    var num = inputNumber
  
  for (i = 0; i&lt;= num; i++){
  
  var numString = i.toString();
  
  if (numString.includes('3')) {
    numList.push("I'm sorry Dave, I can't do that")
  } 
  
  else if (numString.includes('2')) {
    numList.push("boop!")
  }
  else if (numString.includes('1')) {
    numList.push("beep!")
  }
  
    numList.push(i)
  }
  return numList;
  }
  </code></pre>
  
  <p>What I'm getting </p>
  
  <p>input: 9</p>
  
  <p>Output: 0,beep!,1,boop!,2,I'm sorry Dave, I can't do that,3,4,5,6,7,8,9,</p>
  
  <p>What I want:</p>
  
  <p>input: 9</p>
  
  <p>Output: 1,2, I'm sorry Dave, I can't do that, 4, 5, 6, 7, 8, 9</p>