Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. var checkIfArray = function(arr){
  2. if( arr.constructor !== Array ){
  3. console.log("You have to put an Array");
  4. return false
  5. }
  6. return true
  7. }
  8.  
  9. var checkIfArrayIsBigEnough = function(ind, arr){
  10. if( ind > arr.length - 1) {
  11. console.log("your array isnt that long")
  12. return false
  13. }
  14. return true
  15. }
  16.  
  17.  
  18.  
  19. var itemGrabber = function(arr, ind) {
  20. if( !checkIfArray(arr) || !checkIfArrayIsBigEnough(ind, arr) ){
  21. console.log("It didnt pass")
  22. return
  23. }
  24. console.log("It did pass")
  25. }
  26.  
  27. var letters = ["a", "b", "c"];
  28.  
  29.  
  30. itemGrabber("dogs", 0);
  31. itemGrabber(letters, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement