Translate Java code in javascript

Hello,

is it possible to translate this snap of code into Javascript ?

The method checks wether an isin code (string) is correct or not :

      public boolean validIsin(String src) {
            int s = 0;
            int a = (src.length() == 12) ? 1 : 2;
            for (int i = src.length() - 1; i >= 0; i--) {
                  int c = src.charAt(i);
                  if (c > '9') {
                        c -= ('A' - 10);
                        s += (3 - a) * (c / 10) + a * c + (a - 1) * (c % 10) / 5;
                  } else {
                        c -= '0';
                        s += a * c + (a - 1) * (c / 5);
                        a = 3 - a;
                  }
            }
            s %= 10;
            return ((10 - s % 10) % 10) == 0;
      }

Must return true for the following strings :
US0378331005
AU0000XVGZA3
GB0002634946
Should return false if you modify some numbers in the above strings.

Thank you for any help.
LVL 9
matthew016Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

malfunction84Commented:
function validIsin(src) {
    var s = 0;
    var a = (src.length == 12) ? 1 : 2;
    for (var i = src.length - 1; i >= 0; i--) {
        var c = src.charCodeAt(i);
        if (c > '9'.charCodeAt(0)) {
            c -= ('A'.charCodeAt(0) - 10);
            s += (3 - a) * Math.floor(c / 10) + a * c + Math.floor((a - 1) * (c % 10) / 5);
        } else {
            c -= '0'.charCodeAt(0);
            s += a * c + (a - 1) * Math.floor(c / 5);
            a = 3 - a;
        }
    }
    s %= 10;
    return ((10 - s % 10) % 10) == 0;
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
malfunction84Commented:
You should probably tag this with Java as well.
matthew016Author Commented:
thanks, works great,
what do you mean tag this with java ?
malfunction84Commented:
I mean add the "Java" tag to your question so it's easier for others to find later.  Your question requires familiarity with both Java and Javascript.

It may not be possible to change the tags after the question is posted.  If that is the case, you can post a request in the Community boards for one of the admins to change the tags.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.