-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23. DashInsert.js
More file actions
39 lines (33 loc) · 970 Bytes
/
23. DashInsert.js
File metadata and controls
39 lines (33 loc) · 970 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
function DashInsert(str) {
// code goes here
var arr=[];
for(x=0;x<str.length;x++){
arr.push(str[x]);
<<<<<<< HEAD
<<<<<<< HEAD
if(str[x]%2>0&&str[x+1]%2>0){
arr.push("-");
}
// used %2>0 instead of %2!=0 because %2!=0is showing as true for undefined answers
=======
//had to use "%2>0" instead of "%2!=0" because x+1 triggers undefined which results in true for !=
=======
>>>>>>> Challenge to manipulate a string using dashes (-).
if(str[x]%2>0&&str[x+1]%2>0){
arr.push("-");
}
>>>>>>> Challenge to manipulate a string using dashes (-).
}
return arr.join("");
}
// keep this function call here
// to see how to enter arguments in JavaScript scroll down
<<<<<<< HEAD
<<<<<<< HEAD
DashInsert(readline());
=======
DashInsert(readline());
>>>>>>> Challenge to manipulate a string using dashes (-).
=======
DashInsert(readline());
>>>>>>> Challenge to manipulate a string using dashes (-).