Stuck in a exercise to enter in a coding bootcamp

Hi i’m stuck in this exercise for the past couple of days.
Could please some one help me. I’m feeling quite noob about this…

Instructions

Create a function named extractPassword which takes an array of characters (which includes some trash characters) and returns a string with only valid characters (a - z, A - Z, 0 - 9).

Here’s an example:

extractPassword([‘a’, ‘-’, ‘~’, ‘1’, ‘a’, ‘/’]); // should return the string ‘a1a’
extractPassword([’~’, ‘A’, ‘7’, ‘/’, ‘C’]); // should return the string ‘A7C’

var extractPassword= ('1', '2','a','B','C','~'); { var newPass=(); for(var i =0; i <extractPassword.length ; i++){ var x = extractPassword(i); if(('a'<= x && x <='z') ||('A'<=x && x<='Z') ||('0'<=x && x<='9')){ newPass.push(x); } } return newPass.join(""); }

could some one please correct me or point me in the right direction.

I see a few things wrong with this.

  1. since ES6 you could use let and const to declare variables witch is the preferred way but you can use var

  2. The parameters were put in as if you were calling the function instead of defining it.

  3. The variable newPass needs to have [] instead of () on line 3

  4. For the if statement you don’t put () around each condition instead you put 1 set around all the conditions.

thanks man! got it solved!
see you next exercise :smile:

No problem. Don’t forget to mark it as a solution as long as it solved your problem.