JavaScript project for beginner - Get help on debugging my code

Hi guys, my code doesn’t run properly and I have no idea why is that :(( help me please this got the deadline on 3rd October but im stuck here right now crying for help

this below is the html that you can link with the code above, thanks guys.

I think you will need to be more specific about what is not working.

i think that should be the function validateType when extract the index of the array, but i can’t fix it :frowning:

We need the requirements and a clear description of the problem.


  1. In validateAndCalc log out your variables before the big if statement.

console.log(vName, tour, lunch, vPeople, vId);

  1. Not really sure what is going on in validateCheckDigit but first you convert str to a String, then you convert it to a Number and perform math on the values, then you try to use string methods on the returned numbers. You are also not using resultA for anything. As I said, I’m not really sure what the function is supposed to do but it would also help if you named your variables better, I have no idea what resultA and resultB mean.

  2. It does not look like the validateID is doing what is it supposed to do. I don’t see a DOM output when it is invalid.

1 Like

oh as you can see that resultB is for comparing with checkDigit, cuz they want to know if resultB == checkDigit then ID is right, but if not then ID is invalid.

Here is the case: If resultB has 2 or more digits, we keep adding the digits and return them in resultB till we have a 1-digit returnB, later then we check with checkDigit.

Whatever the logic is you can’t perform string operations on numbers. You can’t check the length and you can’t call charAt on resultB.

var resultB = parseInt('12345'.charAt(1)) + parseInt('12345'.charAt(3));
console.log(resultB) // 6
console.log(typeof resultB) // number
resultB.length // undefined

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.