Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. /*Write a JavaScript program to test if an
  2. array of integers of length 2 contains 1 or a 3.*/
  3.  
  4. function checkArray(array) {
  5. if (array[0] == 1) {
  6. return 1 + " appears on first position";
  7. } else if (array[0] == 3) {
  8. return 3 + " appears on first position";
  9. } else if (array[1] == 1) {
  10. return 1 + " appears on second position";
  11. } else if (array[1] == 3) {
  12. return 3 + " appears on second position";
  13. } else {
  14. return "none of them appears on second position";
  15. }
  16. }
  17.  
  18. console.log(checkArray([0, 3]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement