How to convert isbn 13 to isbn 10?

Javascript newbie - what is wrong with this statement?

  • if (passed ==true && (isbn.value.length != "13" || isbn.value.length != "10")) { alert("The ISBN can only be 10 or 13 digits long."); passed = false; ...show more

  • Answer:

    if (passed && ((isbn.value.length = 13 || isbn.value.length = 10) == false)) 1) length is a number, not a string. 2) "boolean value == true" is called a pleonasm - the interpreter has to evaluate passed, then it has to evaluate (passed == true), which is the same value as passed. It's wasted effort. 3) You can drop passed altogether, unless it's usually false - just check for the length (even if passed is usually false, executing the code doesn't cost much): if (!(isbn.value.length = 13 || isbn.value.length = 10)) is only 3 evaluations.

Q2YQARBIKQYWGHQPCAXCIHCIHY at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

well, first of all, what are you trying to do. don't worry I'll help you noob.

Kit K

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.