-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.js
More file actions
44 lines (41 loc) · 818 Bytes
/
strings.js
File metadata and controls
44 lines (41 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function strings(input){
var a = input.split(',');
for(i=1; i<a.length; i++){
even = [];
odd = [];
for(var j=0; j<a[i].length; j++){
if(j % 2 == 0) even.push(a[i][j]);
else odd.push(a[i][j]);
}
console.log(even.join('') + " " + odd.join(''));
}
}
//strings("3,yash damani,Ravi Teja,ths,jhsddfj");
function arrays(input){
var b = [];
var result = [];
for(var i = 0; i<input.length; i++){
if(input[i].length!==undefined){
for(var j = 0; j<input[i].length; j++){
b.push(input[i][j]);
}
}
else{
b.push(input[i]);
}
}
console.log(b);
for(let i=0; i<b.length; i++) {
counter = 0;
for(j=0; j<b.length; j++){
if(b[i] == b[j] && i!==j){
counter++;
}
}
if(counter<1) {
result.push(b[i]);
}
}
return result;
}
console.log(arrays([[1,2,4,3],[2,1,3,4]]));