Retired

Who will win the dice roll (retired)

Description:

Story

Two friends decided to roll two dices and compete to see who will get the bigger amount.

Challenge

Create a function whoWin, that takes two objects p1 and p2 in which are stored the values name and diceNums (an array with two digits from 1 to 6). This function should calculate the sum of numbers from two dice of each player and determine the winner or draw.

Example

let p1 = {
  "name": "Slava",
  "diceNums": [6,6]
}
let p2 = {
  "name": "Anthony",
  "diceNums": [5,6]
}
// whoWin should return "Slava wins! He has 12 and Anthony has 11."
let p1 = {
  "name": "Dylan",
  "diceNums": [6,6]
}
let p2 = {
  "name": "John",
  "diceNums": [6,6]
}
// whoWin should return "DRAW!"
Arrays
Strings

Stats:

CreatedJul 22, 2023
Warriors Trained18
Total Skips0
Total Code Submissions51
Total Times Completed10
JavaScript Completions10
Total Stars0
% of votes with a positive feedback rating44% of 8
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes3
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • montegray Avatar
  • SagePtr Avatar
Ad