Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- txt = 'avi, moshe, aharon, levi, itzik, keren, mor, MosHe, noy, david'
- var x = txt.split(", ")
- for (index = 0; index < x.length; index++) {
- if (x[index] == "keren") {
- x[index] = "liron"
- }
- }
- // show index from 1 to 4
- //alert(x.slice(0, 4))
- // print last index
- alert(x.slice(-1))
- // number of names in the list
- alert(x.length)
- //replace all 'moshe' in list to 'eli'
- for (index = 0; index < x.length; index++) {
- if (x[index].toLowerCase() == "moshe") {
- x[index] = "eli"
- }
- }
- alert(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement