Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myFunction(text) {
- let array=[]
- for (let i=0; i<text.length; i++){
- let tempArr = text[i].split(' ')
- command=tempArr[0]
- value=tempArr[1]
- if(command=="add"){
- array.push(value)
- }
- if(command=="remove"){
- array.splice(value, 1)
- }
- }
- for(let j=0; j<array.length; j++){
- console.log(array[j])
- }
- }
- //myFunction(['add 3', 'add 5', 'add 7']);
Add Comment
Please, Sign In to add comment