I'm trying to make a more advanced scientific calculator. I am having trouble figuring out how to do this type of calculation. I have an array of numbers and I want to check which of the given numbers are divisible by 3.
I would like both the collection of numbers divisible by 3 and the count of those numbers.
For example, on input of:
const collection = [
{ text: "0", value: 0 },
{ text: "1", value: 1 },
{ text: "2", value: 2 },
{ text: "3", value: 3 },
{ text: "4", value: 4 },
{ text: "5", value: 5 },
{ text: "6", value: 6 },
{ text: "7", value: 7 },
{ text: "8", value: 8 },
{ text: "9", value: 9 },
{ text: "10", value: 10 },
{ text: "11", value: 11 },
{ text: "12", value: 12 },
];
I would like to get output like:
"There are 5 divisible numbers by 3: 0, 3, 6, 9, 12"
How can I do that?