forked from niomic-id/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray-split.js
More file actions
47 lines (44 loc) · 997 Bytes
/
array-split.js
File metadata and controls
47 lines (44 loc) · 997 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
45
46
47
// var panggilSplit = ()=>{
// var kalimat = {
// nama : "Bagus Junaedi Ardiyanto",
// }
// //console.log(kalimat.nama)
//
// var ubah = kalimat.nama.split(" ")
// var nama = ubah[0].split("")
// var showindex = nama.indexOf("m")
//
// //return showindex
//
// if (showindex === 0) {
// var ubahdata = nama.splice(showindex,1,"j")
// return nama
// }
// else if (showindex === 1){
// ubahdata = nama.splice(showindex,1,"u")
// return nama
// }
// else {
// return "BAD"
// }
// }
//
// console.log(panggilSplit());
var panggildata = ()=>{
var kalimat = {
kata:"hello world"
}
console.log(kalimat.kata);
const ubahdata = kalimat.kata.split("")
//return ubahdata
const barisdata = ubahdata.indexOf(" ")
ubahdata.splice(barisdata,1)
//ubah posisi L
ubahdata.splice(3,0,"l")
ubahdata.splice(9,1)
//ubah posisi // O
ubahdata.splice(6,0,"o")
ubahdata.splice(8,1)
return ubahdata.join('')
}
console.log(panggildata());