SlideShare a Scribd company logo
1 of 1
Download to read offline
The displayCard(rank, suit) function displays a playing card to the console, given the rank (1-13)
and suit (0-3). Write a for loop that calls displayCard() 10 times, each time with a random rank and
suit. // rank should be a number between 1 and 13, and suit between 0 and 3. Javascript please.
Nothing complicated please.
function displayCard(rank, suit) {
switch (rank) {
case 1: rank = "A"; break;
case 10: rank = "T"; break;
case 11: rank = "J"; break;
case 12: rank = "Q"; break;
case 13: rank = "K"; break;
default: if (rank < 1 || rank > 13) {
console.log("Bad rank value: " + rank);
}
}
switch (suit) {
case 0: suit = ""; break;
case 1: suit = ""; break;
case 2: suit = ""; break;
case 3: suit = ""; break;
default: console.log("Bad suit value: " + suit);
}
console.log("");
console.log("" + rank + suit + " ");
console.log(" ");
console.log(" " + rank + suit + "");
console.log("");
}
displayCard(5, 0); // 5 of Hearts
displayCard(13, 1); // K of Diamonds
displayCard(1, 2); // A of Clubs
displayCard(10, 3); // 10 of Spades

More Related Content

More from hershbudhia1

Assume you have a population of 29000 people where 2 of the.pdf
Assume you have a population of 29000 people where 2 of the.pdfAssume you have a population of 29000 people where 2 of the.pdf
Assume you have a population of 29000 people where 2 of the.pdfhershbudhia1
 
At least one of the answers above is NOT correct Let A16.pdf
At least one of the answers above is NOT correct Let A16.pdfAt least one of the answers above is NOT correct Let A16.pdf
At least one of the answers above is NOT correct Let A16.pdfhershbudhia1
 
At January 1 2020 Monty Companys outstanding shares inclu.pdf
At January 1 2020 Monty Companys outstanding shares inclu.pdfAt January 1 2020 Monty Companys outstanding shares inclu.pdf
At January 1 2020 Monty Companys outstanding shares inclu.pdfhershbudhia1
 
At December 31 2021 Sullivan Corporation teported the stoc.pdf
At December 31 2021 Sullivan Corporation teported the stoc.pdfAt December 31 2021 Sullivan Corporation teported the stoc.pdf
At December 31 2021 Sullivan Corporation teported the stoc.pdfhershbudhia1
 
At December 31 2025 Cullumber Company had 514000 shares of.pdf
At December 31 2025 Cullumber Company had 514000 shares of.pdfAt December 31 2025 Cullumber Company had 514000 shares of.pdf
At December 31 2025 Cullumber Company had 514000 shares of.pdfhershbudhia1
 
At an altitude of 4km and latitude of 227 degrees the Co.pdf
At an altitude of 4km and latitude of 227 degrees the Co.pdfAt an altitude of 4km and latitude of 227 degrees the Co.pdf
At an altitude of 4km and latitude of 227 degrees the Co.pdfhershbudhia1
 
At a recent meeting the manager of a national call center f.pdf
At a recent meeting the manager of a national call center f.pdfAt a recent meeting the manager of a national call center f.pdf
At a recent meeting the manager of a national call center f.pdfhershbudhia1
 
At a fashion retailer there are 3 cashiers providing checko.pdf
At a fashion retailer there are 3 cashiers providing checko.pdfAt a fashion retailer there are 3 cashiers providing checko.pdf
At a fashion retailer there are 3 cashiers providing checko.pdfhershbudhia1
 
Asymptotic Notations 6 points For each pair of the followi.pdf
Asymptotic Notations 6 points For each pair of the followi.pdfAsymptotic Notations 6 points For each pair of the followi.pdf
Asymptotic Notations 6 points For each pair of the followi.pdfhershbudhia1
 
At a fashion retailer there are 6 cashiers providing checko.pdf
At a fashion retailer there are 6 cashiers providing checko.pdfAt a fashion retailer there are 6 cashiers providing checko.pdf
At a fashion retailer there are 6 cashiers providing checko.pdfhershbudhia1
 
At a certain university 55 of the students are studying Ast.pdf
At a certain university 55 of the students are studying Ast.pdfAt a certain university 55 of the students are studying Ast.pdf
At a certain university 55 of the students are studying Ast.pdfhershbudhia1
 
Asymptotics Recall that the assumption MLR6 states u N0 .pdf
Asymptotics Recall that the assumption MLR6 states u  N0 .pdfAsymptotics Recall that the assumption MLR6 states u  N0 .pdf
Asymptotics Recall that the assumption MLR6 states u N0 .pdfhershbudhia1
 
Aswer all 5 Question 11 Disposable income is calculated by s.pdf
Aswer all 5 Question 11 Disposable income is calculated by s.pdfAswer all 5 Question 11 Disposable income is calculated by s.pdf
Aswer all 5 Question 11 Disposable income is calculated by s.pdfhershbudhia1
 
At a ceetain cologe 16 of al students come from cutside th.pdf
At a ceetain cologe 16 of al students come from cutside th.pdfAt a ceetain cologe 16 of al students come from cutside th.pdf
At a ceetain cologe 16 of al students come from cutside th.pdfhershbudhia1
 
At 01 can it be concluded that the average birthweight fr.pdf
At 01 can it be concluded that the average birthweight fr.pdfAt 01 can it be concluded that the average birthweight fr.pdf
At 01 can it be concluded that the average birthweight fr.pdfhershbudhia1
 
Aswer all Question Question 1 Marys nominal income is 4000.pdf
Aswer all Question Question 1 Marys nominal income is 4000.pdfAswer all Question Question 1 Marys nominal income is 4000.pdf
Aswer all Question Question 1 Marys nominal income is 4000.pdfhershbudhia1
 
aSupply Chain Management SCM is like the backbone for any.pdf
aSupply Chain Management SCM is like the backbone for any.pdfaSupply Chain Management SCM is like the backbone for any.pdf
aSupply Chain Management SCM is like the backbone for any.pdfhershbudhia1
 
aSuppose that we identify 145 women 50 to 54 years of age .pdf
aSuppose that we identify 145 women 50 to 54 years of age .pdfaSuppose that we identify 145 women 50 to 54 years of age .pdf
aSuppose that we identify 145 women 50 to 54 years of age .pdfhershbudhia1
 
aSuppose for PolyU students the average price of smartpho.pdf
aSuppose for PolyU students the average price of smartpho.pdfaSuppose for PolyU students the average price of smartpho.pdf
aSuppose for PolyU students the average price of smartpho.pdfhershbudhia1
 
Asthma is a common respiratory pathology How do you think t.pdf
Asthma is a common respiratory pathology How do you think t.pdfAsthma is a common respiratory pathology How do you think t.pdf
Asthma is a common respiratory pathology How do you think t.pdfhershbudhia1
 

More from hershbudhia1 (20)

Assume you have a population of 29000 people where 2 of the.pdf
Assume you have a population of 29000 people where 2 of the.pdfAssume you have a population of 29000 people where 2 of the.pdf
Assume you have a population of 29000 people where 2 of the.pdf
 
At least one of the answers above is NOT correct Let A16.pdf
At least one of the answers above is NOT correct Let A16.pdfAt least one of the answers above is NOT correct Let A16.pdf
At least one of the answers above is NOT correct Let A16.pdf
 
At January 1 2020 Monty Companys outstanding shares inclu.pdf
At January 1 2020 Monty Companys outstanding shares inclu.pdfAt January 1 2020 Monty Companys outstanding shares inclu.pdf
At January 1 2020 Monty Companys outstanding shares inclu.pdf
 
At December 31 2021 Sullivan Corporation teported the stoc.pdf
At December 31 2021 Sullivan Corporation teported the stoc.pdfAt December 31 2021 Sullivan Corporation teported the stoc.pdf
At December 31 2021 Sullivan Corporation teported the stoc.pdf
 
At December 31 2025 Cullumber Company had 514000 shares of.pdf
At December 31 2025 Cullumber Company had 514000 shares of.pdfAt December 31 2025 Cullumber Company had 514000 shares of.pdf
At December 31 2025 Cullumber Company had 514000 shares of.pdf
 
At an altitude of 4km and latitude of 227 degrees the Co.pdf
At an altitude of 4km and latitude of 227 degrees the Co.pdfAt an altitude of 4km and latitude of 227 degrees the Co.pdf
At an altitude of 4km and latitude of 227 degrees the Co.pdf
 
At a recent meeting the manager of a national call center f.pdf
At a recent meeting the manager of a national call center f.pdfAt a recent meeting the manager of a national call center f.pdf
At a recent meeting the manager of a national call center f.pdf
 
At a fashion retailer there are 3 cashiers providing checko.pdf
At a fashion retailer there are 3 cashiers providing checko.pdfAt a fashion retailer there are 3 cashiers providing checko.pdf
At a fashion retailer there are 3 cashiers providing checko.pdf
 
Asymptotic Notations 6 points For each pair of the followi.pdf
Asymptotic Notations 6 points For each pair of the followi.pdfAsymptotic Notations 6 points For each pair of the followi.pdf
Asymptotic Notations 6 points For each pair of the followi.pdf
 
At a fashion retailer there are 6 cashiers providing checko.pdf
At a fashion retailer there are 6 cashiers providing checko.pdfAt a fashion retailer there are 6 cashiers providing checko.pdf
At a fashion retailer there are 6 cashiers providing checko.pdf
 
At a certain university 55 of the students are studying Ast.pdf
At a certain university 55 of the students are studying Ast.pdfAt a certain university 55 of the students are studying Ast.pdf
At a certain university 55 of the students are studying Ast.pdf
 
Asymptotics Recall that the assumption MLR6 states u N0 .pdf
Asymptotics Recall that the assumption MLR6 states u  N0 .pdfAsymptotics Recall that the assumption MLR6 states u  N0 .pdf
Asymptotics Recall that the assumption MLR6 states u N0 .pdf
 
Aswer all 5 Question 11 Disposable income is calculated by s.pdf
Aswer all 5 Question 11 Disposable income is calculated by s.pdfAswer all 5 Question 11 Disposable income is calculated by s.pdf
Aswer all 5 Question 11 Disposable income is calculated by s.pdf
 
At a ceetain cologe 16 of al students come from cutside th.pdf
At a ceetain cologe 16 of al students come from cutside th.pdfAt a ceetain cologe 16 of al students come from cutside th.pdf
At a ceetain cologe 16 of al students come from cutside th.pdf
 
At 01 can it be concluded that the average birthweight fr.pdf
At 01 can it be concluded that the average birthweight fr.pdfAt 01 can it be concluded that the average birthweight fr.pdf
At 01 can it be concluded that the average birthweight fr.pdf
 
Aswer all Question Question 1 Marys nominal income is 4000.pdf
Aswer all Question Question 1 Marys nominal income is 4000.pdfAswer all Question Question 1 Marys nominal income is 4000.pdf
Aswer all Question Question 1 Marys nominal income is 4000.pdf
 
aSupply Chain Management SCM is like the backbone for any.pdf
aSupply Chain Management SCM is like the backbone for any.pdfaSupply Chain Management SCM is like the backbone for any.pdf
aSupply Chain Management SCM is like the backbone for any.pdf
 
aSuppose that we identify 145 women 50 to 54 years of age .pdf
aSuppose that we identify 145 women 50 to 54 years of age .pdfaSuppose that we identify 145 women 50 to 54 years of age .pdf
aSuppose that we identify 145 women 50 to 54 years of age .pdf
 
aSuppose for PolyU students the average price of smartpho.pdf
aSuppose for PolyU students the average price of smartpho.pdfaSuppose for PolyU students the average price of smartpho.pdf
aSuppose for PolyU students the average price of smartpho.pdf
 
Asthma is a common respiratory pathology How do you think t.pdf
Asthma is a common respiratory pathology How do you think t.pdfAsthma is a common respiratory pathology How do you think t.pdf
Asthma is a common respiratory pathology How do you think t.pdf
 

Recently uploaded

The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
Vani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational TrustVani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational TrustSavipriya Raghavendra
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTDR. SNEHA NAIR
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...M56BOOKSTORE PRODUCT/SERVICE
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxvidhisharma994099
 
10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdfJayanti Pande
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceApostolos Syropoulos
 

Recently uploaded (20)

The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
Vani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational TrustVani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
Vani Magazine - Quarterly Magazine of Seshadripuram Educational Trust
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptx
 
10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf10 Topics For MBA Project Report [HR].pdf
10 Topics For MBA Project Report [HR].pdf
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial Intelligence
 

The displayCardrank suit function displays a playing card.pdf

  • 1. The displayCard(rank, suit) function displays a playing card to the console, given the rank (1-13) and suit (0-3). Write a for loop that calls displayCard() 10 times, each time with a random rank and suit. // rank should be a number between 1 and 13, and suit between 0 and 3. Javascript please. Nothing complicated please. function displayCard(rank, suit) { switch (rank) { case 1: rank = "A"; break; case 10: rank = "T"; break; case 11: rank = "J"; break; case 12: rank = "Q"; break; case 13: rank = "K"; break; default: if (rank < 1 || rank > 13) { console.log("Bad rank value: " + rank); } } switch (suit) { case 0: suit = ""; break; case 1: suit = ""; break; case 2: suit = ""; break; case 3: suit = ""; break; default: console.log("Bad suit value: " + suit); } console.log(""); console.log("" + rank + suit + " "); console.log(" "); console.log(" " + rank + suit + ""); console.log(""); } displayCard(5, 0); // 5 of Hearts displayCard(13, 1); // K of Diamonds displayCard(1, 2); // A of Clubs displayCard(10, 3); // 10 of Spades