Skip to content

Commit 60c357e

Browse files
committed
Update displayOperands to handle optional operands
The displayOperands function previously did not distinguish between optional and required operands. This change updates the function to display optional operands within square brackets.
1 parent 7c27a8c commit 60c357e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/App.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ class App extends Component {
3131
displayOperands(operands) {
3232
let all = "";
3333
let comma = "";
34+
3435
for (let i = 0; i < operands.length; i++) {
35-
all += comma + operands[i].name;
36+
if (operands[i].optional) {
37+
all += comma + "[," + operands[i].name + "]";
38+
} else {
39+
all += comma + operands[i].name;
40+
}
3641
comma = ",";
3742
}
43+
3844
return all;
3945
}
46+
4047

4148
displayMnemonic(item) {
4249
const spaces = " ";

0 commit comments

Comments
 (0)