Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Write a JavaScript program to test if an
- array of integers of length 2 contains 1 or a 3.*/
- function checkArray(array) {
- if (array[0] == 1) {
- return 1 + " appears on first position";
- } else if (array[0] == 3) {
- return 3 + " appears on first position";
- } else if (array[1] == 1) {
- return 1 + " appears on second position";
- } else if (array[1] == 3) {
- return 3 + " appears on second position";
- } else {
- return "none of them appears on second position";
- }
- }
- console.log(checkArray([0, 3]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement