Question : convert Java hash function to Javascript

I've tried to convert the following Java function
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
	public static int hashCode(char[] s) {
		int hash = 0;

		for (int i = 0; i < s.length; i++) {
			hash = s[i] + ((hash << 5) - hash);
		}

		return hash;
	}

into javascript as follows:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function hash(s)
{
	var hash = 0;

	for (var i = 0; i < s.length; i++) {
		hash = s[i] + ((hash << 5) - hash);
	}
	
	return hash;
}

The Java version returns 69609650 for "Hello", whereas the JS version returns "oNan".
Can someone tell me how to fix the JS version?  I assume it has something to do with casting.

Answer : convert Java hash function to Javascript

Sorry, forgot to add 1 to the dimensions:

1:
Cells(2, 5).Resize(ubound(vardata, 1) + 1, ubound(vardata, 2) + 1).Value = varData
Random Solutions  
 
programming4us programming4us