Results 1 to 7 of 7
  1. #1
    doger057's Avatar
    Join Date
    Apr 2018
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0

    Question How do i make a space between vars in JavaScript?

    hey guys, I don't actually know whether this is supposed to be in this forum or not. anyways, here is the code and how it looks like if opening it in the browser. im a total noob so don't be triggered XD im trying to get a space between the vars.
    Code:
    var r1 ="999999999999999999999999999999999999999999999999999999999999999999999"; // makes var with numbers
    var l1 = r1.length; // makes a var. it doesnt calculate it just counts the length of the numbers. this is 69 because there are 69  9's
    document.write(l1); // it writes it on your screen/executes the code? im not sure what is this im 12
    var r2 ="moop"; // makes a var with letters by using "" i think. i still use it for numbers aswell anyway.
    var s1 = r2.substring(1, 4) // it only starts showing from the second letter to the fourth. that will make oop
    document.write(s1); // same as the above. only its a different var





    Thanks

    - - - Updated - - -

    It might be hard to read the code btw, but I attached another image so you can easily see the problem and the code


    - - - Updated - - -

    still looking for answers
    Attached Thumbnails Attached Thumbnails
    test.PNG  

    69.PNG  

    Last edited by doger057; 06-11-2019 at 01:32 PM.

  2. #2
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    what exactly is the question?

  3. #3
    heiron70's Avatar
    Join Date
    Sep 2014
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    4
    What do you mean by space? the space in javascript is this "&nbsp"

  4. #4
    doger057's Avatar
    Join Date
    Apr 2018
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by MikeRohsoft View Post
    what exactly is the question?
    well, im noob so i dont even know it that well,
    but since i used length, adding a space to the number that displays wont matter, since then it will simply show 70 instead of 69
    im probably looking for a space that doesnt actually count with length. so i will have a space between 69 and oop yet it shouldnt change the 69 to 70

    - - - Updated - - -

    Quote Originally Posted by heiron70 View Post
    What do you mean by space? the space in javascript is this "&nbsp"
    maybe that could work, but ill search first on how I should use it since I don't actually know how.
    since I have tried using it real quick but everywhere I place it, whatever comes after &nbsp doesn't display?
    Last edited by doger057; 06-15-2019 at 11:59 AM.

  5. #5
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    Quote Originally Posted by doger057 View Post
    well, im noob so i dont even know it that well,
    but since i used length, adding a space to the number that displays wont matter, since then it will simply show 70 instead of 69
    im probably looking for a space that doesnt actually count with length. so i will have a space between 69 and oop yet it shouldnt change the 69 to 70

    - - - Updated - - -


    maybe that could work, but ill search first on how I should use it since I don't actually know how.
    since I have tried using it real quick but everywhere I place it, whatever comes after * doesn't display?
    oohh, now i understand what u want xD sweet
    i think you are trying to do that:
    Code:
    var r1 ="999999999999999999999999999999999999999999999999999999999999999999999"; 
    var l1 = r1.length; 
    
    var r2 ="moop"; 
    var s1 = r2.substring(1, 4);
    
    document.write(l1 + " " + s1);
    if u want to create a "line feed" you have to replace " " with "<br>"

  6. #6
    heiron70's Avatar
    Join Date
    Sep 2014
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    4
    Mike was correct sorry didn't understand the question
    Code:
    document.write( "+(var1)+ " " + (var2)+ " " + (var3)+"); /* another way
    and yes <br> is line feed

  7. #7
    power_dice's Avatar
    Join Date
    Dec 2019
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    0
    With ES6 we have what we call Template Strings. It is the same logic but mor readable. Example

    Code:
    const name = "John";
    console.log(`Hello, ${name}!`);
    // Prints: Hello, John!
    And you can do logic too

    Code:
    console.log(`I am ${2019-1991} years old.`);
    // Prints: I am 28 years old.
    Good coding

Similar Threads

  1. [Help Request] HOW WOULD I MAKE A BIG VAULT THAT WOULD CARRY 16 spaces
    By R.O.T.M.G rocks in forum Realm of the Mad God Private Servers Help
    Replies: 1
    Last Post: 12-03-2017, 01:55 AM
  2. [How to make a space effect signature] [GIMP] [VIDEO]
    By blackbirdz0 in forum Tutorials
    Replies: 5
    Last Post: 08-23-2014, 09:57 AM
  3. Help! how do i make a jap warrock name?
    By gmgundamx7 in forum WarRock - International Hacks
    Replies: 4
    Last Post: 04-04-2007, 11:07 AM
  4. How'd you make these?
    By Twisty in forum Art & Graphic Design
    Replies: 1
    Last Post: 03-13-2007, 03:27 AM
  5. how can i make game hack?!!!!
    By UnknownID in forum General Game Hacking
    Replies: 2
    Last Post: 02-07-2006, 07:21 PM