Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Roam45 authored Nov 2, 2024
1 parent a67241f commit cbc5b35
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ <h2>Output:</h2>
variables[varName] = parseFloat(value);
}
// Handle string
else if (/^".*"|'[^']*'$/.test(value)) {
variables[varName] = value.replace(/^["']|["']$/g, ''); // Remove quotes
else if (/^".*"$/.test(value) || /^'.*'$/.test(value)) {
variables[varName] = value.slice(1, -1); // Remove quotes
}
continue;
}
Expand All @@ -91,6 +91,11 @@ <h2>Output:</h2>
result += (variables[varToPrint] !== undefined ? variables[varToPrint] : "Undefined variable") + "\n";
continue;
}

// Handle invalid lines or other commands
if (trimmedLine) {
result += `Error: Unrecognized command: "${trimmedLine}"\n`;
}
}

return result.trim();
Expand Down

0 comments on commit cbc5b35

Please sign in to comment.