Given an array let arr = [1, 2, 3, 4, 5, 6, 7].
I need to write a function that creates a new array and puts values greater than 3 and less than 6 into it. What am I doing wrong?
<code> let arr = [1, 2, 3, 4, 5, 6, 7];
function inBetween() {
let result = [];
for (let num of arr) {
if (num > 3 && num < 6) {
result.push(num);
}
}
}
console.log(inBetween(arr));
</code>
<code> let arr = [1, 2, 3, 4, 5, 6, 7];
function inBetween() {
let result = [];
for (let num of arr) {
if (num > 3 && num < 6) {
result.push(num);
}
}
}
console.log(inBetween(arr));
</code>
let arr = [1, 2, 3, 4, 5, 6, 7];
function inBetween() {
let result = [];
for (let num of arr) {
if (num > 3 && num < 6) {
result.push(num);
}
}
}
console.log(inBetween(arr));
New contributor
Valentina is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.