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 years ago.
Improve this question
I need an easy solution, in javascript, to remove thousands from an integer
for example:
29492 => 20492
1024 => 24
12345 => 10345
How could i do this easily ? the shorter/clearer the better
Even if I agree with Get Off My Lawn, you could have a solution that wok for both, with simple use of modulo.
x = x - (x%10000) + (x%1000)
//29492 => 29492 - 9492 + 492
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 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
I have a data that looks like this
Huawei Y7P Art-L28 (4/64gb) (AAAAAAAAAAAAAA) EXP:02/19/2020
Huawei Y9 prime 2019 (BBBBBBBBBBBBBBB) EXP:07/17/2019
Oppo A31 4gb/128gb (CCCCCCCCCCCCCCC)
Vivo Y15 5000mah 4GB/64GB (1901) (DDDDDDDDDDDDDDD) EXP:06/14/2019
And the I want to get this data
AAAAAAAAAAAAAA
BBBBBBBBBBBBBBB
CCCCCCCCCCCCCCC
DDDDDDDDDDDDDDD
Basically what I want to happen is to extract the data from the set of word but my problem here is that its very unpredictable. It has no pattern at all so its hard to separate the string.
Assuming that you need a substring in last parenthesis:
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(column, '(', -1), ')', 1)
FROM source_table
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 2 years ago.
Improve this question
In python, I can join elements in an array by doing:
print(a)
b=' '.join(a)
print(b)
and I get:
['hhhh', 'hhhh']
hhhh hhhh
How would I do this in js?
It's the same thing, man!
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
b = a.join(' ')
If you want join arrays:
let a ='hhhh';
let b = [].concat(a);
b.concat(a)
If you want to join string
let sth = "a" + " b";
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 4 years ago.
Improve this question
What I have:
add-category
add-exam
a-category1
a-category2
...
a-category[n]
What I need:
I need to cut string on two parts as 'a-category' and '1' or just 'add-exam' if no digit in row.
let str = 'a-category2';
let splitStr = str.split(/(\d+)/);
console.log('string--->' + splitStr[0]);
console.log('digit---->' + splitStr[1]);
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 7 years ago.
Improve this question
I have a two textbox and i want to convert string value such as "apple" and "cat" into appropriate integer value using javascript.
Simple...
var myInt = "cat";
var converted = parseInt(myInt, 10);
console.log(converted);
>>NaN
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 8 years ago.
Improve this question
Hi i was reading a article and found pretty strange results the below code in javascript return 2.
!+[]+!+[]
Can anyone please explain.
Breaking down the expression into the correct order of operations, you have:
(!(+[])) + (!(+[]))
First things first, [] is cast to a number by +, which results in 0. Don't ask me why, it just does :p Probably buried in the specification somewhere.
!0 is simply true
So you end up with true + true, which again casts to numbers, resulting in 1 + 1 = 2
To get nine, you'd need nine repetitions:
!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[] == 9