Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let list = [];
- function highlight(){
- alert('Your word is already in the list..');
- }
- function add_to_list(list){
- let Selection = document.getElementById('selection').value;
- for(let i = 0; i < list.length; i++){
- for(x in list[i]){
- if(x === ''){
- alert('Field is empty');
- }
- if(x === Selection){
- highlight();
- }
- if(x != Selection){
- list.push(x);
- }
- }
- }
- }
- function remove_from_list(list){
- let Selection = document.getElementById('selection').value;
- for(let i = 0; i < list.length; i++){
- for(x in list[i] == Selection){
- list.pop(x);
- }
- }
- }
- function view(list){
- console.log(list);
- }
- view.onclick = function(){
- view(list);
- }
- push.onclick = function(){
- add_to_list(list);
- }
- pop.onclick = function(){
- remove_from_list(list);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement