SeppeB
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
just to see if it will change the equalizer there
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
can you try to add a line to the end of the for-loop
equalizer = Number(equalizer.toFixed(2));
right after the else statement84 replies
KPCKevin Powell - Community
•Created by samidev on 9/26/2023 in #front-end
Auto Closing Tag not showing
it was my plesure, it also happened to me, that's why i noticed it so quickly
8 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
You can try equalizer = Number( (equalizer + 20).toFixed(2))
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
wait, what are you logging?
84 replies
KPCKevin Powell - Community
•Created by samidev on 9/26/2023 in #front-end
Auto Closing Tag not showing
no problemo, happy i could help
8 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
what happens when you try parseFloat(x.toFixed(2))
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
no, the parseFloat was a mistake on my part
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
x is in this case your myNumber, Number is used to parse it back to a number.
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
my bad indeed, it was a brain fart moment xd
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
but yeah, it was some oversight on my part
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
pretty sure it also works for a number
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
i don't think it keeps track, but i don't know for sure.
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
if it's only adding and subtracting, you can try to use parseFloat(yournumber).toFixed(2)
84 replies
KPCKevin Powell - Community
•Created by Brightie on 9/26/2023 in #front-end
Quirky numbers in javascript
pretty sure this is some problem with floating points and bits, don't know exactly how it works, but it's something like, you can't have .5 bits. This is a dummy script i found on StackOverflow that identifies the problem
function test() {
var x = 0.1 * 0.2;
document.write(x);
}
test();
this will result in 0.020000000000000004. it's just because the precision in the floating points isn't that great.
Here is the explanation if you're interested:
https://stackoverflow.com/a/588014
Sadly there is no one way to fix it (as far as i know)84 replies
KPCKevin Powell - Community
•Created by samidev on 9/26/2023 in #front-end
Auto Closing Tag not showing
so, i've noticed that you use a keyup event, but for checking the last pressed key, you actually check the last user input, this is the cause of the duplication. The keyup event is also triggered by modifier keys (ctrl, shift,...). So when you lift those up, it will also execute run & since the last character is still '>', it will run the whole code block again.
This can be fixed by defining the event in the
keyUp="run(event)"
and then checking if event.key === '>'
The other part was a bit more tricky, but with the use of a couple handy console.log()'s; it's easier to understand.
in the tagToClose, you're actually a digit off:
this:
console.log("substring: ", code.substring(cursorPosition - 2, cursorPosition));
logs"1>"
however, this:
console.log("substring: ", code.substring(cursorPosition - 3, cursorPosition-1));
logs"h1"
const tagToClose = code.substring(cursorPosition - 3, cursorPosition - 1);
the split,reverse & join were actually not necessary at this point in the code.
hope this helps!8 replies
KPCKevin Powell - Community
•Created by Matt on 9/6/2023 in #front-end
Centering with Absolute Positioning
happy to help
13 replies
KPCKevin Powell - Community
•Created by Matt on 9/6/2023 in #front-end
Centering with Absolute Positioning
that should also work
13 replies
KPCKevin Powell - Community
•Created by Matt on 9/6/2023 in #front-end
Centering with Absolute Positioning
pretty sure it's transform:translate(-50%,-50%)
13 replies
KPCKevin Powell - Community
•Created by Matt on 9/6/2023 in #front-end
Centering with Absolute Positioning
inset:0;
margin:auto;
the inset is equal to top, bottom, left and right of 0,
after that the margin auto will normally center the blob.
13 replies