Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript function counting cards

let count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }
  if (count > 0) {
    return count + " Bet";
  } else {
    return count + " Hold";
  }
  // Only change code above this line
}

cc(2); cc(3); cc(7); cc('K'); cc('A');
Comment

javascript function counting cards

function cc(card) {
  // Only change code below this line
  var regex = /[JQKA]/;
  if (card > 1 && card < 7) {
    count++;
  } else if (card === 10 || regex.test(card)) {
    count--;
  }

  if (count > 0) return count + " Bet";
  return count + " Hold";

  // Only change code above this line
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: express-roteamento 
Javascript :: translate javascript to english 
Javascript :: highcharts hide gaps 
Javascript :: sequelzie order by 
Javascript :: using multiple dropzones with formik field array 
Javascript :: with jquery Make a style menu that displays paragraphs and hides them according to the style of the slides 
Javascript :: react-native-wagmi-charts 
Javascript :: wordpress how to read jquery 
Javascript :: javascript interview questions and answers pdf 
Javascript :: how to render array buffer binary audio js 
Javascript :: utm to lat long 
Javascript :: onclick switch javascript 
Javascript :: select inputs without specific type js 
Javascript :: image gallery functions 
Javascript :: check if content is overflowing react 
Javascript :: hide navbar and footer on certain pages like dashboard. react-router 
Javascript :: How to create a table with indents from nested JSON in angularjs 
Javascript :: angularjs trying to fix a rack lint error and 500 on GET /cable 
Javascript :: angularjs Ionic styling container 
Javascript :: Json response reactnative fetch login data 
Javascript :: How to make this code cleaner? react native 
Javascript :: reverse array without using another array 
Javascript :: socket.io authentication 
Javascript :: convert json to string curl 
Javascript :: json array form to list object java 
Javascript :: three.js animate object regardless screen fps 
Javascript :: generate package json for existing project 
Javascript :: removevalidators angular 
Javascript :: React Native - iOS Release build crashing 
Javascript :: node-red function string to int 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =