Posts by t_carvalho • 89 points
15 posts
-
-1
votes1
answer74
viewsA: Function created to perform other functions
One of the most important things to think about as a JS program is that, basically, everything is object. Of course this may sound like a generalization, but basically any data structure in…
-
-1
votes1
answer41
viewsA: Best way to know if an object array has the same values, even at different positions
Well, the simplest way would be to loop through one of the arrays and use the method .include(), that returns a Boolean. let arr1 = [1,2,3,4]; let arr2 = [4,2,1,3]; function check(primeira_array,…
-
0
votes1
answer75
viewsA: Limit characters to an amount "x" with javascript
I believe that you are approaching the problem in the wrong way, it is possible to limit the number of digits in the 'input' in a much simpler and local way. Follows a functional code (JS…
javascriptanswered t_carvalho 89 -
0
votes2
answers50
viewsA: Play video from a playlist according to date and time has how?
Well, in data logic... You can use the object Date! To access the values of the object, you must first insert it into a variable: var date = new Date(); From there, you have easy access to…
-
0
votes2
answers21
viewsA: How to use a class selector instead of the id "clock" for the counter to work in multiple instances (Divs)?
Good, I particularly recommend using the method querySelector(), then to select all class elements "clock", you’d call her from inside the document as: document.querySelector(".clock"); // usando…
-
-1
votes2
answers58
viewsA: I made a game in javascript, but I wanted to know how to add Pause and start by pressing only one key
All right, let’s go... Something I didn’t notice in your code was the establishment of the engine to "run" the game. As this involves a procedure that needs to be repeated several times, it is…
javascriptanswered t_carvalho 89 -
2
votes3
answers124
viewsA: How to use a variable within another function?
Well, the two simplest ways are: 1. Call, from within the original scope of the variable, the function you want by passing to variable inside as argument: Call…
javascriptanswered t_carvalho 89 -
0
votes1
answer36
viewsA: Add links to text dynamically without changing element attributes
I’m not sure I understand what you want, but here’s an explanation on how to turn pieces of text into a link, without changing the CSS format the simplest way I can! First, you create, in your CSS…
javascriptanswered t_carvalho 89 -
-1
votes2
answers52
viewsA: How to remove a style font from a string using DOM manipulation?
Whoa, your problem is actually something very simple! Well, you’re getting an element and passing it to HTML inside a DIV, right? So you just say that el.style.fontFamily = '[a fonte que você quer]'…
-
1
votes3
answers32
viewsA: Copy radio value to textarea
You can make a function that modifies the textarea, that receives an item as a value. From this, you implement a click event on each item, indicating to this function, passing to it this.value. For…
-
-4
votes2
answers83
viewsA: Why do we use parameters/arguments in functions?
Well, in the smallest possible response, the parameters capture local scope information, that situation where you call it within another function
-
0
votes2
answers45
viewsA: Hide text by pressing button
Well, apparently you didn’t understand the basis of the DOM, so to clarify... Basically, javascript within an HTML page has the freedom to modify CSS elements within HTML objects, such as the edge…
javascriptanswered t_carvalho 89 -
-1
votes2
answers496
viewsA: Cannot read Property 'addeventlistener' of null Console error
From what I understand, your code has some problems, First... -> You do not have an element with ID 'ligamosPraVoce' inside your HTML. Second... You inserted a .addEventListener() within a…
javascriptanswered t_carvalho 89 -
6
votes1
answer125
viewsQ: Differences between defining object methods using Arrow Function and Function Expression
About "flammable" methods outside objects, I can say that these three forms below act in the same way within my code? Examples: var barquinho = { pedro: () => { console.log("a"); }, tiago:…
-
0
votes1
answer164
viewsQ: What does this code mean/do?
Well, I’m learning to use Javascript, mainly working with index, and I always come across this, but I want to understand what each part means, because I don’t want to use it without really…