This code works as expected the loaded variable increases as the files finish loading.
The next step is to check when the loading is done and then append a button for the user to press to start the scene and call the init function.
To check if the loading is done you simply need to check that the loaded var is greater than or equal to the totalNeededToLoad var.
The only thing left to do is create a visual for the loading bar. This can be done through css, making a bar with its width equal to 100% divided by totalNeededToLoad and then as each file loads increment the width by this found fraction.