+ 1

Imported Code not working

Why does my code run seamlessly on my local code editor but then tends to have bugs when I import it to solo learn. For instance this code for a random password generator that was working in my local editor but now seems to not function in solo learn. https://sololearn.com/compiler-playground/W7fTrQQN27JD/?ref=app

3rd Dec 2024, 3:03 PM
Asobola Donor
Asobola Donor - avatar
3 ответов
+ 3
Ran fine for me. But to answer the question ... code depends on a certain environment. You develop it using certain versions of software, certain folder structures, certain versions of packages, whatever. Then you try to run it on a different environment and something in the new environment is different. Might be a minor thing, but it may be enough to cause issues. In real world corporate environments, we setup development environments and testing environments that are closely matched to the production environment. Our test servers are nearly identical to our production servers. We not only have to test our code for the production environment, we have to do massive testing on code when we are upgrading the environment itself.
3rd Dec 2024, 3:56 PM
Jerry Hobby
Jerry Hobby - avatar
+ 1
Jerry Hobby Alright and ty
3rd Dec 2024, 4:07 PM
Asobola Donor
Asobola Donor - avatar
+ 1
if you're writing your js in the js tab, it's good to wrap the DOM element variable assignments in an onload function. This way, the variables will be properly assigned. The js tab gets loaded earlier than the html tab and this causes assignment issues since js cannot find the DOM elements. Putting the assignment inside the onload functions makes the assignment happen only after the HTML is done loading. onload =()=>{ const passwordDisplay = document.getElementById("passwordDisplay"); const passwordLength = document.getElementById("passwordLength"); const includeUppercase = document.getElementById("includeUppercase"); const includeLowercase = document.getElementById("includeLowercase"); const includeNumbers = document.getElementById("includeNumbers"); const includeSymbols = document.getElementById("includeSymbols"); }
4th Dec 2024, 2:07 AM
Bob_Li
Bob_Li - avatar