Ok. Today we are module 4. While I am waiting for salaad subax, let me share with you function arguments in javascript...Subax wanaagsan. Salaad subax is on about one hour for those who live here in Minneapolis, please don't forget that two rakat..
pray it.. Thanks.....
1. you can do this way and here is the code. You can give function values in default parameters as you can see below...They are 3 ways you can give function arguments..
2. You can the function any number of arguments and tell the function to read as an array. here is and example.function magaceyga(name="Saciid barre",nationality="Somali")
{
console.log("name: "+name,"nationality: "+ nationality);
}
magaceyga();
function sooDaabac(...magacArray)
{
for(let magaceyga of magacArray)
console.log("Magaceyga: "+magaceyga);
}
sooDaabac("saciid","afisoone","Barre");
3. you can do the opposite of the last function argument. You can give arguments and the display it in an array...
These 3 ways you can give function arguments. You as you can we use dots.. It is called Spread operatorfunction fullName(firstname,middlename,lastname)
{
console.log("firstname: "+firstname+" middlename: "+middlename+" lastname: "+lastname);
}
fullName(...["Saciid","Abdirisaq","Barre"]);
Ok.. See u next module
here is full document.
Code: Select all
<!doctype html>
<html>
<meta charset="utf-8">
<head>
<title>Isticmaalka variableka let</title>
</head>
<body>
<script type="text/javascript">
//first way
function magaceyga(name="Saciid barre",nationality="Somali")
{
console.log("name: "+name,"nationality: "+ nationality);
}
magaceyga();
//second way
function sooDaabac(...magacArray)
{
for(let magaceyga of magacArray)
console.log("Magaceyga: "+magaceyga);
}
sooDaabac("saciid","afisoone","Barre");
//third way
function fullName(firstname,middlename,lastname)
{
console.log("firstname: "+firstname+" middlename: "+middlename+" lastname: "+lastname);
}
fullName(...["Saciid","Abdirisaq","Barre"]);
</script>
</body>
</html>
Macalin Afisoone...