Newbie help with Javascript undefined

Hi - First time post and apparently I’m now 8% of a full stack developer. I have run through a couple of the coursework exercises and wanted to attempt a function to validate my understanding. I am stuck with an undefine output at the end of what I was hoping to achieve. Apologies in advance if this is a simple/stupid questions!

// create a new function for reporting the characters of a chose password

const pwGenerator = (passwordInput) => {  
    let characterNumber =0;
    for (const char of passwordInput) {

        // increment character count
        characterNumber++;

        //formatting, add in an extra space for number less than 10 so that password character are aligned 

        if (characterNumber < 10) 

        {
            let output = `No:  ${characterNumber} -: ${char}`;
            console.log(output);

        }

        else {
            let output = `No: ${characterNumber} -: ${char}`;
            console.log(output);
        };
    };
};
console.log(pwGenerator(`3f@r^A"4^'P@rs#E`));

In this example I get what I am looking for but with an ‘undefined’ at the end.

No:  1 -: 3
No:  2 -: f
No:  3 -: @
No:  4 -: r
No:  5 -: ^
No:  6 -: A
No:  7 -: "
No:  8 -: 4
No:  9 -: ^
No: 10 -: '
No: 11 -: P
No: 12 -: @
No: 13 -: r
No: 14 -: s
No: 15 -: #
No: 16 -: E
undefined

you attempt to log the returned result of your pwGenerator function:

console.log(pwGenerator(`3f@r^A"4^'P@rs#E`));

but this function does not return anything, thus you get undefined

Excellent - makes sense now. Turns out changing it to;
pwGenerator(3f@r^A"4^'P@rs#E); works a treat.