Adding up results from for loop + auto break when number in let is reached

I am working on an algoritm that outputs random data for an upcoming movie project I am working on.

I have an RNG called ShotRNG that outputs a number between 1 and 72 (which stands for the length of each shot in frames based on 24 frames per second)

Let’s say I have a usableRunTime let which defines the total usable time.

In this case, usableRunTime = 500

I want a for loop to run and add all of the results from the shotRNG together. Once the total numbers generated by usableRunTime reaches 500 or above, I want the for loop to automatically break.

Can someone help me with this?

I’ve tried for and while loops but I haven’t been able to get it to work yet. Some of my code is underneath:

`

function partSixDivider(){
    console.log ("#006tPOST PRODUCTIONn[DETERMINES ENTIRE FLOW OF THE FILM BASED UPON THE PREVIOUSLY GENERATED PARAMETERS]nn");
}

let usableRunTime = 0;

function convertSecondsToFramesDeclaration() {
    usableRunTime = totalRunTime * 24 - 360;
    return "TOTAL USABLE FRAMES (BASED ON 24FPS):t" + usableRunTime;
}

function shotRNG() {
    return Math.floor(Math.random() * (totalShotSum - 1 + 1)) + 1;
}

function frameRNG() {
    return Math.floor(Math.random() * (72 - 1 + 1)) + 1;
}

function shotVersion() {
    let versionRNG = shotParameterCalculation(1,4)
    return versionRNG;
}

let introFrames = 240; // Based on 10 seconds * 24 frames per second
let outtroFrames = 120; // Based on 5 seconds * 24 frames per second

function filmDeclaration() {
    console.log("FILM OVERVIEW REPORTnn");
    console.log("INTRO tVERSION: N/AtFRAMES: "+ introFrames)
   
    for (let x = 1; x <= usableRunTime; x++) {
        console.log("SHOT " + shotRNG() + ":t" + "VERSION: " +shotVersion()) + "t" + "FRAMES:"
    }

    console.log("OUTTRO tVERSION: N/AtFRAMES: "+ outtroFrames) +"nn"
}

`