Use the parseInt Function - without return

Tell us what’s happening:
Useful, but without a return no way to pass even if you perform all conversions correctly.

Your code so far


function convertToInteger(str) {
  //Line 3&4 work but do not 'return' as mentioned.
  var a = parseInt(str); //Assigns the correct calculations
  alert(a); //Shows the correct calculations
}

convertToInteger("56");
convertToInteger("56");
convertToInteger("77");
convertToInteger("JamesBond");

Welcome @roye! A function always needs to return something, and will always return something, usually undefined if you don’t explicitly use a return statement.

You should return a value here, instead of creating an alert, if I think you’re on the challenge I think you are. Can you share which challenge you are on?

I just wanted to see for myself if I was producing the correct values. When I confrimed with alerts I was able to re-read the question and pass by using a return but the function still was performant. This was a bit confusing. Thought I would share the keyword “return”!