a program in which you write a function formula and it returns zeros in javascript

Here's an example function that takes a formula as a string and returns an array of zeros with the same length as the formula:

index.tsx
function getZeros(formula) {
  const arr = formula.split('');
  const zeros = arr.map(() => 0);
  return zeros;
}
114 chars
6 lines

To use this function, you can pass in the formula string as an argument:

index.tsx
const formula = 'x^2 - 5x + 6';
const zeros = getZeros(formula);
console.log(zeros); // [0, 0, 0, 0, 0, 0]
107 chars
4 lines

This will return an array of zeros with the same length as the formula string, in this case 6.

gistlibby LogSnag