Skip to content
Home » Learning Javascript

Learning Javascript

Javascript

JavaScript is a programming language which is widely utilise in web development. It is a client-side scripting language which can embed into HTML pages to create interactive and dynamic user experiences.

JavaScript was created by Brendan Eich in 1995 and was originally called Mocha, then later changed to LiveScript, and finally to JavaScript. It is a transcribe language, which means the code is set directly by the web browser without the need for compilation.

JavaScript is utilise for a wide range of web development tasks, including:

  • Creating dynamic and interactive user interfaces
  • Validating user input and handling form submissions
  • Animating page elements and creating visual effects
  • Implementing client-side functionality such as pop-ups, tooltips, and dropdown menus
  • Communicating with servers using AJAX requests
  • Building complex web applications using popular JavaScript frameworks like React, Angular, and Vue

JavaScript is supported by all modern web browsers and can also be used outside of web development, such as in server-side programming using Node.js. At Ceegees , we make use of javascript for lot of our work. if you are keen in a software developer career with Ceegees. Its important that you have a good understanding of make sure you have a good understanding of javascript and conventions before you attempt on any of the problems.

Javascript Card Game – OOPs

Excersice

  • Create a folder in your respository and call it javascript
  • Work on the susequent activities under that folder, creating sub folders for every task
  • Raise a PR to master when you are completed with your task.

Task

Model the following actions as objects and actions
with primary objects being the following

  • Card
  • Deck – can contain multiple cards
  • Player – can hold multiple cards
  • Table – Can accomodate multiple players maximum 6

The Models should support the following

  • By default a deck will have 52 cards 13 from each of the suites ( spades, clubs, heart, diamonds)
  • I should be able to add cards to a deck
  • I should be able to remove cards from a deck
  • I should be able to shuffle a deck
  • I should be able to give card to a player who is sitting on a table
  • I should be able to distibute all of the cards from the deck to people sitting on a table
  • I should be able to Identify the list of players with maximum value of cards on the Table
  • Card value calculated – 2 – 10 [integer values ], J = 11, Q – 12 , K – 13 , A – 14
  • I should be able to get the list of players with ascending order of total card values
class Card {
    constructor(suite,value){
        this.suite = suite;
        this.value = value;
    }
    getValue(){
        if (!isNaN(this.value)){
            return this.value;
        } else if (this.value == 'J') {
            return 11;
        }
        // Add more logic here
    }
}


const card1 = new Card("S", "J");
const card2 = new Card("S",5);

console.log(card1.getValue());
console.log(card2.getValue());


const table = new Table();
const p1 = new Player('p1');
const p2 = new Player('p2');
const p3 = new Player('p3');

table.addPlayer(p1);
table.addPlayer(p2);
table.addPlayer(p3);
table.distribute();

p1.getScore();
p2.getScore();
p3.getScore();