Can someone help me figure out how to generate a list of numbers based on two criteria?
- The number must be divisible by 3
- The number must not end with 3
I need to create this list within the first 50 numbers using JavaScript.
Desired Output:
6, 9, 12, 15... 45
My Attempt:
function getNumbers() {
var result = [];
for (var i = 1; i <= 50; i++) {
if (i % 3 == 0 && i % 10 != 3) {
result.push(i);
}
}
return result.toString();
}
console.log(getNumbers())