How to take in different button values as a single string

1 week ago 10
ARTICLE AD BOX

I've been searching the internet all day now, but I just can't find the thing I am looking for (might be language barrier). So I really hope one of you might be able to help me with this.

I'm using the following example to show what I want to do with html & js.

I have 3 Buttons and when clicked they do the buttoninput function in js.

<button value="a" type="button" onclick="buttoninput(this)"> a </button> <button value="b" type="button" onclick="buttoninput(this)"> b </button> <button value="c" type="button" onclick="buttoninput(this)"> c </button> <button value="stop"> this one is so that it won't be an endless input </button>

in JavaScript

let inputvalue = ""; function buttoninput(button) { inputvalue = button.value; // But what do I need to add here so it's not only a single value? console.log(inputvalue); }

But this is where I am getting stuck. I do get the right input, for example button "a". But it's only ever one single letter.

But what if I want to do a combo that goes "aba"?

I would be really gratefull if anyone could help me here or lead me in the right direction.

Read Entire Article