Showing posts with label functions. Show all posts
Showing posts with label functions. 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

Thursday, January 3, 2019

C மொழி 23 வது பகுதி.



இந்த வீடியோவில் சி மொழியில் Call by reference பற்றிய தகவல்களைக் காண இருக்கின்றோம்.


நன்றி
முத்து கார்த்திகேயன்,மதுரை.
மதுரையில் சி, சி++, ஜாவா, டாட்நெட், பிஹெச்பி, பைத்தான், வெப் டிசைனிங்,டேலி( வித் GST), எம்.எஸ்.ஆபிஸ் படிக்க கீழ்கண்ட எண்ணில் அழைக்கவும்.
919629329142 



ads Udanz