+ 1
JS How can I upgrade this simple code?
https://code.sololearn.com/WEEZ86LMLwKn/?ref=app At first I have to apologise for my English language, its not my mother tongue and for now I am not as fluent as I want to be. After this "small" disclaimer I can move on. So I made this simple code just to show random location on Earth and I have some questions. Can I write this simpler? How to make a break between East and North? I tried /n and it didn't worked because its not in a string but in function (probably). What should I learn to remove almost all places where is only water? 71% of Earth's surface is water so somehow I have to remove big chunk of it. PS. Soon I'll try to convert 60 seconds to 1 minute. To make this part of code complete. Thanks in advance! :)
5 Réponses
+ 3
function losuj(){
document.write("North: " + (Math.floor(Math.random()*180)+1)+"° " + (Math.floor(Math.random()*59)+1)+"' "+ (Math.floor(Math.random()*59)+1)+"\"");
document.write("<br>");
document.write(" East: " + (Math.floor(Math.random()*180)+1)+"° " + (Math.floor(Math.random()*59)+1)+"' "+ (Math.floor(Math.random()*59)+1)+"\"");
}
Instead use break tag
+ 2
When you use *alert*, you need to use "\n" to make a linebreak (newline), because you display something by JavaScript, not by HTML.
When you use *document.write*, you need to use HTML's line breaks <br />, because you display by HTML.
+ 2
I cannot add more than one best answer but both of them are helpful, thank u :)
+ 2
Your english will get better the more you learn programming in english, not my native language (mother tongue) is english nor even germanic, but many programming related words in english are now pretty clear for me.
+ 2
It works in both directions, knowing english is helpful to not remembering "src" as "src" but as "source". <ol> as "ordered list" <ul> as "unordered list" and so on. (I am not certain about <ul> and <ol> but it works for me so its ok....I guess.)