Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="pl">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script src="App.js"></script>
</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                // ZADANIE 1 ///////////////

const rockPaperScissors = function (player1, player2) {
    const possibilities = ['papier', 'kamień', 'nożyce'];
    const players = [player1.toLowerCase(), player2.toLowerCase()]; //wielkość liter w argumentach teraz nie ma znaczenia
    let result;

    for (const player of players) {
        if (!possibilities.includes(player)) return alert('Któryś z wyborów jest niepoprawny');
    }

    //comparing results
    if (players[0] === players[1]) result = 'Remis';

    else if ((players[0] === 'papier' && players[1] === 'kamień') || (players[0] === 'kamień' && players[1] === 'nożyce') || (players[0] === 'nożyce' && players[1] === 'papier')) {
        result = 'Gracz 1 wygrywa';
    }
    else result = 'Gracz 2 wygrywa';

    return console.log(result);
}




// ZADANIE 2 //////////////////

const returnBiggestNumber = function (...numbers) {

    if (arguments.length < 2) return alert('Musisz podać co najmniej 2 liczby');
    let numbersArray = [...arguments];

    for (const number of numbersArray) {
        if (typeof number !== 'number' || !isFinite(number)) return `Wartość "${number}" jest niewłaściwa`;
    }

    //sortowanie liczb od najmniejszej do największej
    numbersArray = numbersArray.sort((a, b) => a - b);
    return console.log(`Największa liczba to ${numbersArray[numbersArray.length - 1]}`);
}


// ZADANIE 3 ///////////////

const findVowels = word => {
    if (typeof word !== 'string') return alert(`${word} nie jest ciągiem tekstowym`);
    const vowelsList = ['a', 'ą', 'e', 'ę', 'i', 'o', 'ó', 'u', 'y'];
    let vowelsCounter = 0;


    for (const letter of word.toLowerCase()) {
        if (vowelsList.includes(letter)) {
            vowelsCounter++;
        }
    }
    return console.log(`Liczba spółgłosek w słowie/zdaniu "${word}" to ${vowelsCounter}`);
}

rockPaperScissors('noŻYCe', 'kamień');
returnBiggestNumber(33, 12, 5, 1082, 52, 3.4445);
findVowels('Javascript jest fajny');
              
            
!
999px

Console