Write a method that prompts the user for 3 different integers and
display on the screen on a single line, separated by commas. If one of the
values is repeated, show only the repeated value.
- Use prompt() or createInput() w/ some message to prompt the user to enter the 3 numbers.
- Then apply trim() followed by split() so it becomes an array.
- Force the array to have at max 3 number entries using min() like this:
array.length = min(3, array.length);
- After that apply int() to remove any fractional parts from them.
I didn’t get this requirement part. Do you mean having unique values only?
If that’s so you can create a Set passing your array to it:
Then use the spread ...
syntax to convert it back to array: array = [ ...new Set(array) ];
1 Like