Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fruitOrVegetable(str) {
- let fruits = ["banana", "apple", "kiwi", "cherry", "lemon", "grapes", "peach"];
- let vegetables = ["tomato", "cucumber", "pepper", "onion", "garlic", "parsley"];
- if (fruits.includes(str)) {
- console.log("fruit");
- }
- else if (vegetables.includes(str)) {
- console.log("vegetable");
- }
- else {
- console.log("unknown");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement