Skip to content
Open navbar menu
Sign UpLog In
Profile icon

Aidan

@Aidan72
cool beans.
Aidan72
Aidan72
shared a Post
4 years ago
Importing variables in Javascript
ok so say I have two files, "main1.js" and "main2.js", I have a variable in main1.js that I want to be in sync with main2.js, (let's say the variable
hyperupcall
hyperupcall
From the repl you linked, it won't work because you did not designate your scripts to use ES Modules :). Like this: When you're importing using ES Modules, you don't add scripts tags for them in your HTML because your're asking the server for the file with this line (in your main2.js) import { num } from './main1.js'; It's worth noting that when you write the filename, you have to prefix the file the name with some absolute or relative path "/main.js", "./main.js", or to some url: "https://exa4 years ago
Vandesm14
Vandesm14
Remove the "var" from the statement and it should work.4 years ago
Aidan72
Aidan72
shared a Post
4 years ago
https://repl.it/@Aidan72/PHP-test
ArchieMaclean
ArchieMaclean
Repl doesn't support putting html tags in PHP, sorry :(4 years ago
Aidan72
Aidan72
shared a Post
4 years ago
Hello this is a game that i made, i might make a few more changes here and there but im mostly dont with it.
Incremental Buildings
HTML, CSS, JS
OWEN5179980
OWEN5179980
Could you add the option to change the number format to scientific so that i can better see how much i have, or even just having b, t, q, qn, etc behind the numbers 2 years ago
nwilson2314
nwilson2314
i have a suggestion. can you make a second button that adds multiplier so it makes more buildings/money?3 years ago
nwilson2314
nwilson2314
mmmmm yes building make building3 years ago
Aidan72
Aidan72
shared a Post
4 years ago
Hello! I am making a game that requires some pretty big numbers, so I was wondering how I could change the numbers to scientific notation PS if it wo
a5rocks
a5rocks
Well, I don't really know js, but here's what I think would work: var number = NUMBER_HERE; var suffixes = ["", "k","M","B","T","q","Q","s","S","O","N"]; var suffix = suffixes[Math.floor((String(number).length-1)/3)-1]; var numberwithsuffix = String(number) + suffix; `4 years ago
theangryepicbanana
theangryepicbanana
1.23 * 10**54 years ago
Aidan72
Aidan72
shared a Post
4 years ago
each button has its own error, its acting as if they are undefined even though i know they are https://repl.it/@Aidan72/No-name-game
Geocube101
Geocube101
That error is normally thrown when there is another error in your code in which Javascript is not loaded and therefore, the functions don't exist Line 328: Remove the '6' in front of 'bldg1amountD' Line 321 - 327: There is no html element with that ID 4 years ago
Aidan72
Aidan72
shared a Post
4 years ago
I keep getting this error TypeError: Cannot set property 'innerHTML' of null at bldg1click (https://replbox.repl.it/data/webhosting1/Aidan72/No-na
ArchieMaclean
ArchieMaclean
You need to move your link to the script: to the end of the file (just before the closing ` tag). This is because when you link to a script at the start of a html file, it only gets the html up to the point it was linked to - so it can't get the innerHTML` because it can't find the span with id "money". Please upvote if this helps :)4 years ago