Looking to replace an index in an array of numbers if that index is a number with a certain digit (say "1"). For instance, 414 has a "1" in it, so replace with text like "oops, no "1's"
I have a program to take a number as user input , and create an array that includes all the numbers up to and including the input number. I have 'if else' rules for replacing the offending single digit numbers. Not sure how to target multiple digit numbers that include a given digit.
var one = [1]
var two = [2]
var three =[3]
var userInput = $("#userInput").val();
var arr = [];
for (i=0;i<=userInput;i++) {
arr.push(i);
if (three.includes(arr[i])){
arr.splice(i,1,"I'm sorry, Dave. I'm afraid I can't do that.")
} else if (two.includes(arr[i])){
arr.splice(i,1,"Boob!")
} else if (one.includes(arr[i])){
arr.splice(i,1,"Beep!")
}
};
for numbers like 13, it should trigger the rule for numbers including 3, but instead it just displays 13 like there everything is fine.