Having recently delved into the world of Javascript, I've encountered a challenging problem that has consumed my entire day. Despite attempting to resolve it on my own, I find myself feeling quite stuck.
The structure of my code is relatively simple - I've crafted 5 distinct functions. One function checks for letters, another for numbers, one identifies an open bracket, and the fourth spots a closed bracket. The fifth function is designed to detect full stops. Each of these functions returns a true value.
Next, I created a master function that calls upon these individual functions as needed to generate a numerical output based on the content found within a text string.
At the core of this issue lies a particular line of code:
identity = isWhat(ModCompound[x], ModCompound[y]);
Strangely, removing this line causes the loop to proceed without any hiccups. What could be the underlying mistake causing the crash?
Here's a snippet of the raw code:
<!DOCTYPE html>
<!--
Sjb 19/03/2015
-->
<html>
<head>
<title></title>
</head>
<body>
Chemicals
</br>
Compound: <input id="compound" value="NaCl.2(H20)">
<script>
var identity;
var x;
Compound = document.getElementById('compound').value;
ModCompound = Compound;
ModCompound = ModCompound.split('');
for (i = 0; i < Compound.length; i++){
x = i;
y = i;
document.write(i);
identity = isWhat(ModCompound[x], ModCompound[y]);
document.write(Math.random() + " : " + identity + "</p>");
}
ModCompound= ModCompound.join('');
// Custom Functions
// Function definitions here
</script>
</body>
</html>