Smile Welcome to Nokomis Drama Smile

The website that was made for the students by the students. Here you can find groups, clubs, stuff that happens in class, heads up on tests and just students having the ability to talk and discuss what goes on in the school. However if you come here to try and "slam" a student your account will be suspended for a number of days or terminated depending on what you did. We will know if you make a fake account as well trust us. Rolling Eyes There will be some section's that don't really refer to the school but more so what some of the clubs and what students are into. This site was again made by the students for the students. Enjoy Banana Dance

Staff Online

Latest topics
» FREEDOM PRESS
Tue Apr 28, 2015 1:54 pm by anonymous-helper

» Day 3 C.O.W
Wed Apr 15, 2015 9:00 am by Shadow

» School Calender 14-15
Tue Apr 14, 2015 9:49 am by Shadow

» The Great Debaters Quotes
Tue Apr 14, 2015 9:22 am by Shadow

» Flo Rida - GDFR ft. Sage The Gemini and Lookas
Mon Apr 13, 2015 9:53 am by Shadow

» 360 Achievement Unlocked Generator
Mon Apr 13, 2015 8:58 am by Shadow

» Netflix Accounts
Sun Apr 12, 2015 12:40 pm by Shadow

» [PC]Outlast
Sat Apr 11, 2015 10:11 am by Shadow

» Wii Code Types
Sat Apr 11, 2015 10:09 am by Shadow

Poll

How many Snow Days?

33% 33% [ 1 ]
67% 67% [ 2 ]
0% 0% [ 0 ]

Total Votes : 3

Visitors Counter

hitwebcounter web counter
Available Tracking

Substring Text Tutorial (Console Log)

View previous topic View next topic Go down

Substring Text Tutorial (Console Log)

Post by Shadow on Wed Jan 14, 2015 1:51 pm

Okay this is easy all you really need to know is place holders. I'll use a easy code. We're gonna be making the substring for "Jan" in "January" "Melbourne is" in "Melbourne is great" (note the space!)
and "burgers" in "Hamburgers". Substrings start counting at 0. So it would be like this.

Code:
0 1 2 3 4
 | | | | |
 h e l l o

Okay so we have the place holder's now were gonna move onto the actual code. You first start with console.log

step 1.
Code:
console.log

Step 2. Now add the word/words your making a substring with it would be "January" (Remember the quotations). So now the code looks like this

Code:
console.log("January"

Step 3. Adding the substring. You need to put .substring tells the console what you are doing with said text. Now the code will look like this.

Code:
console.log("January".substring

Step 4. Find the values of letter's. You want the first 3 letter's in January so the values would be 0-3. You would put that in brackets like this again telling the console the values of said word you want to see. (0,3) So now the code will look like this.

Code:
console.log("January".substring(0,3)

Step 5. Closing the code. This is really important without it it will give you a syntax error. You use ); showing that that line is done. So now the finished code is this.


Code:
console.log("January".substring(0,3));

Now it will show Jan instead of January.

Other examples for tutorial

Code:
console.log("January".substring(0,3));
console.log("Melbourne is great".substring(0,12));
console.log("Hamburgers".substring(3,10));


End result (Picture of the console log)



This is my first real tutorial on something other then making a normal command code so all feed back is good. Tell me where I can improve if needed. Being honest I'm not sure how good I did.

_________________

avatar
Shadow
Admin

Posts : 37
Post Points : 4468
Rep : 25

http://nokomisdrama.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum