Any idea why this doesn't pass?

Instructions:

Write function named createRange that will take a number and a default value and return an array of that many values

Example:

if you pass it 4 and "Hello" then it should return ["Hello", "Hello", "Hello", "Hello"]

My code:

function createRange(num, val) {
    let result = [];
    
    for(let i = 0; i < val.length; i++) {
        result.push(val);
    }
    
    
    
    return result;
};

for(let i = 0; i < val.length; i++)

Describe, in plain English, what this should do.

The problem exists in your for loop. I agree with @PortableStick’s comment asking you to put that code into plain language to see if anything jumps out. If it doesn’t, I’d suggest trying to add some console.log() messages within your for loop to see what the values are each instance/loop. That may point you to see that things aren’t evaluating as you intended.

Thanks guys…this did it:

function createRange(num, val) {
    let result = [];
    
    for(let i = 0; i < num; i++) {
        result.push(val);
    }
    
    
    
    return result;
};