Showing posts with label java script. Show all posts
Showing posts with label java script. Show all posts

Thursday, January 7, 2021

ஜாவாஸ்கிரிப்ட் வேரியபிளில் ஃபங்சன்கள்.-2வது பகுதி.

 

 



Varfunction.js

 

function getUserRole(name,role){

    switch (role) {

        case 'admin':

            return `${name} can create and delete courses`;

            break;

        case 'teacher':

            return `${name} can create and delete tests`;

            break;

         case 'student':

             

            return `${name} can attend course and test`;

            break;

            

    

        default:

            return `${name} not have any role`;

            break;

    }

 

}

var user=getUserRole('karthi','teacher');

console.log(user);

console.log(getUserRole('mukesh','student'));

 

output:

C:\Users\Muthu\Desktop\js>node varfunction.js

karthi can create and delete tests

mukesh can attend course and test

நிரல் விளக்கம்.

இதில் getUserRole() என்ற ஃபங்சனுக்கு இரு பாராமீட்டர்கள் செலுத்துப்படுகின்றது.இது switch case ஸ்ட்ரக்சருக்குள் அதற்கேற்ப மதிப்பு ரிடர்ன் செய்யப்படுகின்றது.

ஃபங்சன் அழைக்கப்படும் வரியில் அதன் இடது புறம் உள்ள வேரியபிளில் மதிப்பிருத்தப்பட்டு அதற்கடுத்து பிரிண்ட் செய்யப்படுகின்றது.அல்லது console.log ஸ்டேட்மென்டில் நேரடியாக அழைக்கப்படுகின்றது.

மேலே உள்ள நிரலை கீழே உள்ளவாறு ஒரு வேரியபிளை அறிவித்து ஒரு ஃபங்சனுக்கு மதிப்பிருத்தலாம். வெளியீடு அதே தான்.

Varfunction2.js

var getUserRole= function (name,role){

    switch (role) {

        case 'admin':

            return `${name} can create and delete courses`;

            break;

        case 'teacher':

            return `${name} can create and delete tests`;

            break;

         case 'student':

 

            return `${name} can attend course and test`;

            break;

            

    

        default:

            return `${name} not have any role`;

            break;

    }

 

}

var user=getUserRole('karthi','teacher');

console.log(user);

console.log(getUserRole('mukesh','student'));

 

output:

C:\Users\Muthu\Desktop\js>node varfunction2.js

karthi can create and delete tests

mukesh can attend course and test

குறிப்பு:

ஜாவா ஸ்கிரிப்ட் நிரலை இயக்க node எனக் குறிப்பிட்டு நிரல் பெயர் .js என்ற எக்ஸ்டன்சன் உடன் கொடுக்க வேண்டும்

சான்றாக

Node varfunction.js

இதில் varfunction.js என்பது நிரலின் பெயர்.

நன்றி

-முத்து கார்த்திகேயன்,மதுரை


 

contact:

ப்ரோக்கிராமிங் பற்றி ஆன்லைன் வகுப்பிள் படிக்க கீழே உள்ள எண்ணை தொடர்பு கொள்ளவும்.

91 9629329142

 email id: muthu.vaelai@gmail.com


 

ads Udanz

Friday, February 28, 2020

ஜாவாஸ்கிரிப்ட் பக்கங்கள்-1












ஜாவா ஸ்கிரிப்டில் எவ்வாறு இரட்டை எண் மற்றும் ஒற்றை எண்ணை பிரித்து எவ்வாறு பட்டியலிடுவது என்று காண்போம்.
<!DOCTYPE html>
<html>
    <head>
        <title>JavaScript: Primitive And Pairs Numbers</title>
        <meta charset="windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <script>
            
            var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,19,21,23,25,27];
            
            for(i = 0; i < arr.length; i++)
            {
                if(arr[i]%2 === 0)
                {
                    document.write("<p style='color:green'>Pair Number "+ arr[i] +"</p>");
                }
                
                else
                {
                    document.write("<p style='color:red'>Primitive Number "+ arr[i] +"</p>");
                }
            }
            
        </script>    
    </body>
</html>
மேலே உள்ள நிரலில் arr என்று ஒரு அர்ரே இருக்கின்றது. இதில் எண்கள் சேமிக்கப்பட்டுள்ளது.
அடுத்து வரும் for லூப்பானது 0 வில் ஆரம்பித்து arr என்ற் அர்ரே லெங்க்த் விட குறைவாயிருக்கும் வரை இயங்கும். பொதுவாக லூப் என்பது ஒரு குறிப்பிட்ட நிபந்தனை ட்ரூ ஆக இருக்கும் வரை அதன் பாடிக்குள் இருக்கும் நிரல் வரிகள் திரும்ப திரும்ப ரன் ஆகும்.
இதில் arr[i] என்பதில் i என்பது இண்டெக்ஸ். முதலில் arr[0],arr[1] என்று ஒவ்வொரு எலிமெண்டாக ஆக்சஸ் செய்யப்படுகின்றது.
இதில் அந்த எலிமெண்டை 2-ல் வகுத்தால் 0 மீதி வந்தால் அந்த எலிமெண்ட் pair number. இல்லையெனில் அது primitive number.
% என்பது மாட் ஆபரேட்டர் எனப்படுகின்றது.இது ஒரு எண்னை மற்றொரு எண்ணால் வகுக்கும் பொழுது வரும் மீதியை தரும்.
வெளியீடு:


நன்றி.
முத்து கார்த்திகேயன்,மதுரை.
ads Udanz

Thursday, March 7, 2019

ஜாவா ஸ்கிரிப்ட்-பகுதி-5 சோர்ஸ் கோட் உடன்



Vote.html
<!DOCTYPE html>
<html>
<head>
  
    <title>Page Title</title>
  
    <script >
    var age=19;
    if(age>=18)
    document.write("<h3>Eligible for vote</h3>");
    else{
        document.write("<h3>too young to vote</h3>");
    }
   
   
    </script>
</head>
<body>
   
</body>
</html>
Positive.html
<!DOCTYPE html>
<html>
<head>
   
    <title>Page Title</title>
   
    <script >
    var n=0;
    if(n>0)
    {
        document.write("<h3>positive</h3>");

    }
    else if(n<0)
    {
        document.write("<h3>negative</h3>");

    }
    else{
        document.write("<h3>Zero</h3>");
    }
   
    </script>
</head>
<body>
   
</body>
</html>
Positiveeven.html
<!DOCTYPE html>
<html>
<head>
  
   
    <title>Page Title</title>
  
    <script >
    var a=6;
    if(a>0)
    {
        document.write("positive");
        if(a%2==0)
        {
            document.write("number is positive and even");
        }
        else{
            document.write("number is positive but odd");
        }
    }
    else{
        document.write("negative");
    }
    </script>
</head>
<body>
  
</body>
</html>
நன்றி
முத்து கார்த்திகேயன்,மதுரை.
மதுரையில் c,c++, java, dotnet, php, python, ms-office, tally, photoshop corel draw, web designing படிக்க பின் வரும் தொலை பேசி எண்ணில் தொடர்பு கொள்ளவும்
91 9629329142
மார்க்கெட்டிங் செய்வதற்கு ஆட்கள் தேவை. அதற்கும் மேலே உள்ள எண்ணில் தொடர்பு கொள்ளவும்.

ads Udanz