Conditional Statement are used to perform different actions based on different condition
Expressionif(condition){ block of code }else if(condition){ block of code }else{ block of code }shipping.html
<!DOCTYPE html> <html lang="en"> <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>Country Shipping</title> </head> <body> <div id="shippingInfoId" /> </body> <script type="text/javascript" src="shipping.js"> </html>shipping.js
var countryName = 'USA'; if (countryName == 'USA') { document.getElementById('shippingInfoId').innerText = countryName + '--' + '2-day Shipping'; } else if (countryName == 'Canda') { document.getElementById('shippingInfoId').innerText = countryName + '--' + '3-day Shipping'; } else if (countryName == 'India') { document.getElementById('shippingInfoId').innerText = countryName + '--' + '1-day Shipping'; } else { document.getElementById('shippingInfoId').innerText = 'Other' + '--' + '5-day Shipping'; }
The switch case statement is a multiway branch statement. it provides an easy way to dispatch execution to different parts of code.
Switch case statement in JavaScript is also used for decision making purposes.
switch (expression) { case value1: statement1; break; case value2: statement2; break; . . case valueN: statementN; break; default: statementDefault; }Example switchcase.js
var customerCountry='AUS'; switch (customerCountry) { case 'USA': document.getElementById('shippingInfo').innerText=customerCountry+'2-day Shipping'; break; case 'Canda': document.getElementById('shippingInfo').innerText=customerCountry+'3-day Shipping'; break; case 'INDIA': document.getElementById('shippingInfo').innerText=customerCountry+'--->'+'1-day Shipping'; break; default: document.getElementById('shippingInfo').innerText=customerCountry+'5-day Shipping'; break; }switchCase.Html
<!DOCTYPE html> <html lang="en"> <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>Country Shipping</title> </head> <body> <div id="shippingInfoId" /> </body> <script type="text/javascript" src="switchCase.js"> </html>
Q-1 Which method of the DescribeSObjectResult class allows you to access record types by their developer name? ANS:
getRecordTypeInfosByDeveloperName()
Q-2 Which Apex class includes new methods to verify digital and HMAC signatures? ANS:- System.Crypto
Q-3 Your org has My Domain enabled. What is the most efficient method to obtain a valid session ID to make an HTTP callout from asynchronous Apex code to Salesforce APIs? ANS:-
Use System.UserInfo.getSessionId().
Q-4Which annotation allows a developer to make the result of an Apex method storable for Lightning components?ANS:-
@AuraEnabled(cacheable=true)
Q-5
$Page.IFrameResource
Q-5: Prior to installing an unlocked package, which object should a developer query using the Tooling API to list the packages it depends on? ANS:- SubscriberPackageVersion
TowerMapUtilClasspublic inherited sharing class TowerMapUtilClass { public static ListTowerMapControllerClass.apxcqueryObjects(String theObject, List theFields, String theFilter, String sortField, String sortOrder) { String theQuery = 'SELECT ' + string.join(theFields, ','); theQuery += ' FROM ' + theObject; if(!String.isEmpty(theFilter)) { theQuery += ' WHERE ' + theFilter; } if(!String.isEmpty(sortField)) { theQuery += ' ORDER BY ' + sortField; if(!String.isEmpty(sortOrder)) { theQuery += ' ' + sortOrder; } } return database.query(theQuery); } }
public inherited sharing class TowerMapControllerClass { @AuraEnabled public static ListAdd below code Towermap.cmpgetAllTowers() { String theObject = 'Tower__c'; List theFields = new List {'Id', 'Name', 'State__r.Name', 'Tower_Location__Latitude__s', 'Tower_Location__Longitude__s'}; String theFilter = ''; String sortField = 'Name'; String sortOrder = 'ASC'; List allTowers = TowerMapUtilClass.queryObjects(theObject, theFields, theFilter, sortField, sortOrder); return allTowers; } }
<lightning:map mapMarkers="{! v.mapMarkers }" markersTitle = "{!v.markersTitle}" zoomLevel="5" />
trigger AccountTrigger on Account (after insert,before insert,after update) { if(Trigger.IsAfter && Trigger.IsUpdate){
set accountSetID=new set();
for(Account AccountDetail:Trigger.new){
system.debug('Account Name'+AccountDetail.Name);
system.debug('AccountDetail.id'+AccountDetail.id);
accountSetID.add(AccountDetail.id);//Store ALl Account ID in Set
}
system.debug('accountSetID'+accountSetID.size());
List contactList=[SELECT LastName,FirstName FROM Contact WHERE ACCOUNTID=:accountSetID];//All Contacts
for(Contact ContactDetail:contactList){
ContactDetail.FirstName='IBM'+ ContactDetail.FirstName;
}
system.debug('contactList'+contactList.size());
system.debug('Contact Name'+contactList[0].FirstName);
update contactList;
}
}
trigger AccountTrigger on Account (after insert,before insert,after update) {
If(Trigger.IsBefore){
for(Account AccountDetail:Trigger.New){
If(AccountDetail.Type=='Prospect'){
AccountDetail.AnnualRevenue=5;//Update AnnualRevenue
}
}
}
AND(
NOT(ISBLANK(AccountId)),
MailingPostalCode <> Account.ShippingPostalCode
)
The reverse() method reverses the elements in an array.
Syntax:arrayName.reverse()
Example:-
var programming = ["c#", "c","java","apex"]; var programmingReverseOrder = programming.reverse(); alert(programmingReverseOrder);
it will be print like
apex,java,c,c#
JavaScript Array concat() Method
it returns combine of records from two arrays.
Example:-
var programming = ["c#", "c","java","apex"]; var dataBaseRelated = ["SQL", "SOQL", "MySQL"]; var application = programming.concat(dataBaseRelated); alert(application);
It will print like this
c#,c,java,apex,SQL,SOQL,MySQL
JavaScript Array length Property
length:it returns size(no.of items ) of an array
Example:-
var languageArray=['c#','c','java']; //its diplay like c#,c,java alert(languageArray); //remove last item using pop method var arraylength=languageArray.length; alert(arraylength);
//it will print 3(no of items in languageArray is 3)