Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to attempt to get a value from a site and calculate it.
At the moment when entering the command
document.getElementById("txtTehtav")
I recieve the answer along the lines of
<a class="thrida" id="txtTehtav" name="txtTehtav">3x3=</a>
My goal would be to separate the value (3x3) into X and Y (X x Y)
How would I be able to accomplish that?
Any help is appreciated.
const textValue = document.getElementById("txtTehtav").innerText; // Will return 3x3=
const [x, y] = textValue.substr(0, textValue.length - 1).split('x').map((n) => parseInt(n))
const muliplication = x*y;
Try this, you will get the text
document.getElementById("txtTehtav").textContent
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 days ago.
Improve this question
Today I saw this code:
e = [div] (div is html object)
if (e.empty(), y) {y.$sheet = e;}
How JS define y?
What is y.$sheet?
I tried to y = e.empty(), but it doesn't work (error with defining y.$sheet = e
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I want to know how we can loop through and add pixel values?
Example,
let testArray = [{width: '150px'}, {width : '150px'}]
So i want to loop through it and have to return total value i.e '300px'
Can someone please help me?
let sumWidth = 0
testArray.forEach((object)=>{
sumWidth+= parseInt(object.width.slice(0,-2))
}
let result = sumWidth.toString() + 'px'
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am stuck with this problem. I have a function to accept the path and also the same time I have a variable that I want to condition with.
Here is my problem: I want to make a string type that will act as an access to my variable.
In my situation, I have a roles.operation variable which I want to access it dynamically.
The roles variable has an array with the values of:
roles.operations = ['document','article','document-type'];
with this variable I want this to be access dynamically.
Here is what I've tried, which in replacePath i have the value of document-type:
export const createVariable = (roles,path) => {
const replacePath = path.replace(/-/g,"_");
const finalPath = window[`roles.operations.${replacePath}`];
console.log(finalPath);
}
this gives me undefined.
Try this way:
const finalPath = window['roles']['operations'][replacePath];
or
const finalPath = window.roles.operations[replacePath];
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm developing simple js neural network and need to create javascript function (derivative of entered by user) before learning starts.
I know about evaluate(), but i think it'll be slowly than simple function.
That is what i want:
const derivative = math.derivative('x^2/sin(2x)', 'x');
const derivative_func = derivative.please_stay_func();
...
while(1) alert(derivate_func(12)) //:) alert result of (2 * 12 * Math.sin(2*12) - 2 * Math.pow(12, 2) * Math.cos(2*12)) / Math.pow(sin(2*12), 2)
Is it real? And maybe i'm not right about speed. Maybe there is some better ways - write here.
i am on mobile, please edit this
maybe this is want you want to do
const countThings = (customValue) ==>{
let x = 'x^2/sin(x)';
let y = 'x';
x = math.parse(x)
y = math.parse(y)
return math.derivative(x, y).evaluate({x:customValue});}
console.log(countThings(12))
and don't do while(1) alert because it will keep alerting
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Convert
var a = [['12ae11ee12-1bhb222','2019-10-10T19:46.19.632z','a123']]
to
var a= ['12ae11ee12-1bhb222','2019-10-10T19:46.19.632z','a123']
I dont want two square brackets in front and end.
I want output
a[2] = 'a123'
The best way to do is just assigning the first value to the array:
var a = [['12ae11ee12-1bhb222','2019-10-10T19:46.19.632z','a123']];
a = a[0];
console.log(a);
But the right way of dealing it should be making sure that the endpoint or whatever that outputs should output correctly.
You can use Array.prototype.flat().
console.log([['12ae11ee12-1bhb222','2019-10-10T19:46.19.632z','a123']].flat());
This solution works if it's extremely nested too:
console.log([
['12ae11ee12-1bhb222'],
['2019-10-10T19:46.19.632z', 'a123']
].flat());