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

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
ย 
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
ย 
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
ย 
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
ย 
Assume you are given a pointer to the root node of a complet.pdf
Assume you are given a pointer to the root node of a complet.pdfAssume you are given a pointer to the root node of a complet.pdf
Assume you are given a pointer to the root node of a complet.pdfhershbudhia1
ย 
Assume you have two lists named list1 and list2 that are of .pdf
Assume you have two lists named list1 and list2 that are of .pdfAssume you have two lists named list1 and list2 that are of .pdf
Assume you have two lists named list1 and list2 that are of .pdfhershbudhia1
ย 
Assuming a parent isotope with a halflife 45 billion year.pdf
Assuming a parent isotope with a halflife 45 billion year.pdfAssuming a parent isotope with a halflife 45 billion year.pdf
Assuming a parent isotope with a halflife 45 billion year.pdfhershbudhia1
ย 
Assume that you have a class that has an integer pointer as .pdf
Assume that you have a class that has an integer pointer as .pdfAssume that you have a class that has an integer pointer as .pdf
Assume that you have a class that has an integer pointer as .pdfhershbudhia1
ย 
Assume there are no taxes or risk of bankruptcy The assets .pdf
Assume there are no taxes or risk of bankruptcy The assets .pdfAssume there are no taxes or risk of bankruptcy The assets .pdf
Assume there are no taxes or risk of bankruptcy The assets .pdfhershbudhia1
ย 
The figure below describes the process of crossing over in .pdf
The figure below describes the process of crossing over in .pdfThe figure below describes the process of crossing over in .pdf
The figure below describes the process of crossing over in .pdfhershbudhia1
ย 
The Finance Committee will oversee the financial activities .pdf
The Finance Committee will oversee the financial activities .pdfThe Finance Committee will oversee the financial activities .pdf
The Finance Committee will oversee the financial activities .pdfhershbudhia1
ย 
The Financial Accounting Standards Board FASB is a private.pdf
The Financial Accounting Standards Board FASB is a private.pdfThe Financial Accounting Standards Board FASB is a private.pdf
The Financial Accounting Standards Board FASB is a private.pdfhershbudhia1
ย 
The figure below shows a simple network Using the BellmanF.pdf
The figure below shows a simple network Using the BellmanF.pdfThe figure below shows a simple network Using the BellmanF.pdf
The figure below shows a simple network Using the BellmanF.pdfhershbudhia1
ย 
The figure here shows the current dwarf planets of our solar.pdf
The figure here shows the current dwarf planets of our solar.pdfThe figure here shows the current dwarf planets of our solar.pdf
The figure here shows the current dwarf planets of our solar.pdfhershbudhia1
ย 
The figure below shows two membrane proteins A and B inv.pdf
The figure below shows two membrane proteins  A and B  inv.pdfThe figure below shows two membrane proteins  A and B  inv.pdf
The figure below shows two membrane proteins A and B inv.pdfhershbudhia1
ย 
The FBI wants to determine the effectiveness of their 10 10 .pdf
The FBI wants to determine the effectiveness of their 10 10 .pdfThe FBI wants to determine the effectiveness of their 10 10 .pdf
The FBI wants to determine the effectiveness of their 10 10 .pdfhershbudhia1
ย 
The Fibonacci numbers are defined by the series 0 1 1 2 .pdf
The Fibonacci numbers are defined by the series 0 1 1 2 .pdfThe Fibonacci numbers are defined by the series 0 1 1 2 .pdf
The Fibonacci numbers are defined by the series 0 1 1 2 .pdfhershbudhia1
ย 
The Ethisphere instituteethispherecom every year publishe.pdf
The Ethisphere instituteethispherecom every year publishe.pdfThe Ethisphere instituteethispherecom every year publishe.pdf
The Ethisphere instituteethispherecom every year publishe.pdfhershbudhia1
ย 

More from hershbudhia1 (20)

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
ย 
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
ย 
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
ย 
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
ย 
Assume you are given a pointer to the root node of a complet.pdf
Assume you are given a pointer to the root node of a complet.pdfAssume you are given a pointer to the root node of a complet.pdf
Assume you are given a pointer to the root node of a complet.pdf
ย 
Assume you have two lists named list1 and list2 that are of .pdf
Assume you have two lists named list1 and list2 that are of .pdfAssume you have two lists named list1 and list2 that are of .pdf
Assume you have two lists named list1 and list2 that are of .pdf
ย 
Assuming a parent isotope with a halflife 45 billion year.pdf
Assuming a parent isotope with a halflife 45 billion year.pdfAssuming a parent isotope with a halflife 45 billion year.pdf
Assuming a parent isotope with a halflife 45 billion year.pdf
ย 
Assume that you have a class that has an integer pointer as .pdf
Assume that you have a class that has an integer pointer as .pdfAssume that you have a class that has an integer pointer as .pdf
Assume that you have a class that has an integer pointer as .pdf
ย 
Assume there are no taxes or risk of bankruptcy The assets .pdf
Assume there are no taxes or risk of bankruptcy The assets .pdfAssume there are no taxes or risk of bankruptcy The assets .pdf
Assume there are no taxes or risk of bankruptcy The assets .pdf
ย 
The figure below describes the process of crossing over in .pdf
The figure below describes the process of crossing over in .pdfThe figure below describes the process of crossing over in .pdf
The figure below describes the process of crossing over in .pdf
ย 
The Finance Committee will oversee the financial activities .pdf
The Finance Committee will oversee the financial activities .pdfThe Finance Committee will oversee the financial activities .pdf
The Finance Committee will oversee the financial activities .pdf
ย 
The Financial Accounting Standards Board FASB is a private.pdf
The Financial Accounting Standards Board FASB is a private.pdfThe Financial Accounting Standards Board FASB is a private.pdf
The Financial Accounting Standards Board FASB is a private.pdf
ย 
The figure below shows a simple network Using the BellmanF.pdf
The figure below shows a simple network Using the BellmanF.pdfThe figure below shows a simple network Using the BellmanF.pdf
The figure below shows a simple network Using the BellmanF.pdf
ย 
The figure here shows the current dwarf planets of our solar.pdf
The figure here shows the current dwarf planets of our solar.pdfThe figure here shows the current dwarf planets of our solar.pdf
The figure here shows the current dwarf planets of our solar.pdf
ย 
The figure below shows two membrane proteins A and B inv.pdf
The figure below shows two membrane proteins  A and B  inv.pdfThe figure below shows two membrane proteins  A and B  inv.pdf
The figure below shows two membrane proteins A and B inv.pdf
ย 
The FBI wants to determine the effectiveness of their 10 10 .pdf
The FBI wants to determine the effectiveness of their 10 10 .pdfThe FBI wants to determine the effectiveness of their 10 10 .pdf
The FBI wants to determine the effectiveness of their 10 10 .pdf
ย 
The Fibonacci numbers are defined by the series 0 1 1 2 .pdf
The Fibonacci numbers are defined by the series 0 1 1 2 .pdfThe Fibonacci numbers are defined by the series 0 1 1 2 .pdf
The Fibonacci numbers are defined by the series 0 1 1 2 .pdf
ย 
The Ethisphere instituteethispherecom every year publishe.pdf
The Ethisphere instituteethispherecom every year publishe.pdfThe Ethisphere instituteethispherecom every year publishe.pdf
The Ethisphere instituteethispherecom every year publishe.pdf
ย 

Recently uploaded

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
ย 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
ย 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
ย 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
ย 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
ย 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
ย 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
ย 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
ย 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
ย 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
ย 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
ย 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
ย 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
ย 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
ย 
Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...
Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...
Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...Nguyen Thanh Tu Collection
ย 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
ย 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
ย 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
ย 

Recently uploaded (20)

Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
ย 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ย 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
ย 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
ย 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
ย 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
ย 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
ย 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
ย 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
ย 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
ย 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
ย 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
ย 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
ย 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
ย 
Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...
Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...
Tแป”NG ร”N TแบฌP THI Vร€O LแปšP 10 Mร”N TIแบพNG ANH Nฤ‚M HแปŒC 2023 - 2024 Cร“ ฤรP รN (NGแปฎ ร‚...
ย 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
ย 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
ย 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
ย 

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