I am trying to take an array containing decimal numbers and increase each value by a decimal number chosen by a user input.
Ultimately I am trying to take an HSL light value from a base color chosen by a user, and if it's less than 0.5 I want to render 5 divs with incremented light values starting at the user's light input. If the value is greater than 0.5 I want to render 5 divs with decremented light values starting at the user's input.
function App() {
let i = 0,
floats = [];
const userInput = 0.3;
while (i < 0.5) {
i = (i + 0.1).toFixed(1);
floats.push(i);
i = parseFloat(i);
}
console.log(userInput + floats);
I can't explain the results that I'm receiving in accurate terms. It shows the array values with the input value together in one array, except that there is no comma between the user input and the array. Here is an example of the results that I'm receiving.
0.30.1,0.2,0.3,0.4,0.5
lightdeclared?0.30.1,0.2,0.3,0.4,0.5. Could you clarify please?