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 cbc5b35 commit ffaa2db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ <h2>Output:</h2>
// Handle string
else if (/^".*"$/.test(value) || /^'.*'$/.test(value)) {
variables[varName] = value.slice(1, -1); // Remove quotes
} else {
result += `Error: Invalid value assigned to ${varName}\n`;
}
continue;
}
Expand All @@ -88,7 +90,11 @@ <h2>Output:</h2>
const printMatch = trimmedLine.match(/print\((var\.\w+)\)/);
if (printMatch) {
const varToPrint = printMatch[1];
result += (variables[varToPrint] !== undefined ? variables[varToPrint] : "Undefined variable") + "\n";
if (variables[varToPrint] !== undefined) {
result += variables[varToPrint] + "\n";
} else {
result += `Undefined variable: ${varToPrint}\n`;
}
continue;
}

Expand Down

0 comments on commit ffaa2db

Please sign in to comment.