Skip to content

JavaScript Great Vowel harmony

CODEPEN


HTML

    <div class="container">
        <div id="box" class="d-flex align-content-center flex-wrap">
            <h2 class="text-center">Büyük Ünlü Uyumu</h2>
            <input type="text" id="kelime">
            <button onclick="myFunction()" class="btn btn-dark">BUL</button>
        </div>
    </div>

CSS

 body{
     
    #box{
        height:100vh;
        width: 200px;
        margin: 0 auto;

        input{
            width: 200px;
            outline:none;
        }
        button{
            margin: 10px auto;
        }
        
    }
    
 }

JS

        let kalin_sayisi = 0;
        let ince_sayisi = 0;
        function myFunction(){
            let kelime = document.getElementById("kelime").value;
            let harfler = Array.from(kelime);
            harfler.forEach(function(x){
                let kalın = ["a","ı","o","u"];
                let ince = ["e","i","ö","ü"];
                kalın.forEach(function(a){
                    if( x == a){
                        kalin_sayisi += 1;
                    }

                },
                ince.forEach(function(a){
                    if( x == a ){
                       ince_sayisi += 1; 
                    }
                })
                )
            }
            )
            if( ince_sayisi > 0 && kalin_sayisi > 0){
                alert("büyük ünlü uyumuna uyulmamıştır")
            }
            else if( ince_sayisi > 0 && kalin_sayisi == 0){
                alert("büyük ünlü uyumuna uyulmuştur")
            }
            else if( ince_sayisi == 0 && kalin_sayisi > 0){
                alert("büyük ünlü uyumuna uyulmuştur")
            }
        }
        

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: