Necesito ayuda para comprender cómo const colorIntervals puede recibir dos argumentos como devolución de llamada (como se muestra al final).
La tarea es implementar la función colorFence(length) , donde length es la longitud total de la valla. Esta función debería devolver otra función a la que se puede llamar con argumentos left y right , donde 0 ≤ left ≤ right < length . La función devuelta colorea el segmento de la valla de izquierda a derecha (inclusive) en el color negro y devuelve la longitud total restante de la valla blanca.
Un ejemplo de interacción es el siguiente:
const colorIntervals = colorFence(20); colorIntervals(18, 18); // The remaining length of the white fence is 19. colorIntervals(0, 3); // The remaining length of the white fence is 15. colorIntervals(17, 19); // The remaining length of the white fence is 13 (since segment 18 was already painted). colorIntervals(0, 19); // The remaining length of the white fence is 0.Su pregunta describe con precisión lo que necesita hacer:
A continuación encontrará un esqueleto de pseudocódigo. Intente adaptar estos requisitos al pseudocódigo.
function first(a) { console.log("first", a) return second } function second(b, c) { console.log("second", b, c) } const firstFunctionExecution = first(1) firstFunctionExecution(2, 3) firstFunctionExecution(4, 5)