- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Determining full house in poker - JavaScript
The “full house in poker” is a situation when a player, out of their five cards, has at least three cards identical. We are required to write a JavaScript function that takes in an array of five elements representing a card each and returns true if there's a full house situation, false otherwise.
Example
Following is the code −
const arr2 = ['K', '2', 'K', 'A', 'J']; const isFullHouse = arr => { const copy = arr.slice(); for(let i = 0; i < arr.length; ){ const el = copy.splice(i, 1)[0]; if(copy.includes(el)){ copy.splice(copy.indexOf(el), 1); if(copy.includes(el)){ return true; } }else{ i++; } }; return false; }; console.log(isFullHouse(arr1)); console.log(isFullHouse(arr2));
Output
Following is the output in the console −
true false
- Related Articles
- Returning poker pair cards - JavaScript
- Determining isomorphic strings JavaScript
- Determining a pangram string in JavaScript
- Determining beautiful number string in JavaScript
- How to Play Poker?
- Determining happy numbers using recursion JavaScript
- Determining rightness of a triangle – JavaScript
- Determining whether numbers form additive sequence in JavaScript
- Determining rank on basis of marks in JavaScript
- HTML5 video full preload in JavaScript
- Setting full screen iframe in JavaScript?
- Determining sum of array as even or odd in JavaScript
- House Robber in Python
- Determining the User IP Address in Node
- Critical factors in determining the Capital Structure

Advertisements