From 46391d7ff722df1d228217fc7b435bfd78cf3a8f Mon Sep 17 00:00:00 2001 From: Linda Njau Date: Tue, 11 Jun 2024 11:52:51 +0300 Subject: [PATCH] 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. `vd,vs2,vs1,[,vm]` --- src/App.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/App.js b/src/App.js index d69dd7f..3cb8b45 100644 --- a/src/App.js +++ b/src/App.js @@ -39,6 +39,23 @@ class App extends Component { }; } + displayOperands(operands) { + let all = ""; + let comma = ""; + + for (let i = 0; i < operands.length; i++) { + if (operands[i].optional) { + all += comma + "[," + operands[i].name + "]"; + } else { + all += comma + operands[i].name; + } + comma = ","; + } + + return all; + } + + displayMnemonic(item) { const spaces = " ";