JavaScript Fundamentals II


Initially published on 24/06/2015
Picture
Start with: Post 1 String length with greater & lesser symbols "Srinath".length > 3 true "Srinath".length < 3 false Logging We use logging to print our statements and results console.log("hello") hello console.log(7*7) 49 Different if ... else ... conditions  Only if if("Sachin".length >= 5 ) { console.log("The Master"); } if ... else ... if("Sachin".length >= 5 ) { console.log("The Master"); } else { console.log("Blaster"); } if ... else ... with equivalence if( 10 === 10) { console.log("It's Tendulkar"); } else { console.log("It's Sachin"); } if ... else ... with / operation if( 16/4 === "yuvi".length) { console.log("The fiery debutant"); } else { console.log("The debutant"); } if ... else ... with * operation if("dravid".length * 2/(2+1) === 2) { console.log("The Wall"); } else { console.log("Jammy"); } Modulo console.log(14 % 3); if ... else ... with % operation if(14 % 2 === 0) { console.log("No reminder"); } else { console.log("There is a reminder"); } Substring  Substring method is used to take values between defined indices. "One day International".substring(4,7); [indexing starts from 0, 0-O,n-1,e-2, ....] [space is character i.e. it takes 3 position] console.log("One day International".substring(4,7)); Logging using variables var myScore = 50; console.log(myScore); var captain = "Dada"; console.log(captain); (* The above exercises are available at codeacademy)

Leave a comment


Please note, comments must be approved before they are published