Trim String

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€86.14
List Price:  €120.60
You save:  €34.46
£75.77
List Price:  £106.09
You save:  £30.31
CA$140.05
List Price:  CA$196.08
You save:  CA$56.02
A$152.75
List Price:  A$213.86
You save:  A$61.10
S$129.79
List Price:  S$181.71
You save:  S$51.92
HK$778.59
List Price:  HK$1,090.06
You save:  HK$311.47
CHF 80.48
List Price:  CHF 112.68
You save:  CHF 32.19
NOK kr1,015.54
List Price:  NOK kr1,421.80
You save:  NOK kr406.25
DKK kr643.39
List Price:  DKK kr900.77
You save:  DKK kr257.38
NZ$175
List Price:  NZ$245.02
You save:  NZ$70.01
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,228.73
List Price:  ৳17,120.71
You save:  ৳4,891.98
₹8,994.18
List Price:  ₹12,592.21
You save:  ₹3,598.03
RM413.15
List Price:  RM578.43
You save:  RM165.28
₦144,745.52
List Price:  ₦202,649.52
You save:  ₦57,904
₨28,176.09
List Price:  ₨39,447.65
You save:  ₨11,271.56
฿3,203.67
List Price:  ฿4,485.27
You save:  ฿1,281.60
₺4,242.17
List Price:  ₺5,939.21
You save:  ₺1,697.03
B$537.12
List Price:  B$751.99
You save:  B$214.87
R1,712.97
List Price:  R2,398.23
You save:  R685.25
Лв168.52
List Price:  Лв235.93
You save:  Лв67.41
₩146,901.96
List Price:  ₩205,668.62
You save:  ₩58,766.66
₪325.43
List Price:  ₪455.62
You save:  ₪130.18
₱5,865.61
List Price:  ₱8,212.09
You save:  ₱2,346.47
¥15,602.16
List Price:  ¥21,843.65
You save:  ¥6,241.48
MX$1,831.60
List Price:  MX$2,564.31
You save:  MX$732.71
QR366.07
List Price:  QR512.51
You save:  QR146.44
P1,336.69
List Price:  P1,871.42
You save:  P534.72
KSh12,928.70
List Price:  KSh18,100.70
You save:  KSh5,172
E£4,753.35
List Price:  E£6,654.88
You save:  E£1,901.53
ብር15,640.38
List Price:  ብር21,897.16
You save:  ብር6,256.77
Kz91,234.01
List Price:  Kz127,731.27
You save:  Kz36,497.25
CLP$92,959.70
List Price:  CLP$130,147.30
You save:  CLP$37,187.60
CN¥706.90
List Price:  CN¥989.70
You save:  CN¥282.79
RD$6,257.36
List Price:  RD$8,760.56
You save:  RD$2,503.19
DA13,031.68
List Price:  DA18,244.87
You save:  DA5,213.19
FJ$227.30
List Price:  FJ$318.23
You save:  FJ$90.93
Q767.59
List Price:  Q1,074.66
You save:  Q307.06
GY$20,952.92
List Price:  GY$29,334.92
You save:  GY$8,382
ISK kr12,766.72
List Price:  ISK kr17,873.92
You save:  ISK kr5,107.20
DH926.11
List Price:  DH1,296.60
You save:  DH370.48
L1,699.08
List Price:  L2,378.78
You save:  L679.70
ден5,308.64
List Price:  ден7,432.31
You save:  ден2,123.66
MOP$803.45
List Price:  MOP$1,124.87
You save:  MOP$321.41
N$1,710.78
List Price:  N$2,395.16
You save:  N$684.38
C$3,685.51
List Price:  C$5,159.87
You save:  C$1,474.35
रु14,346.56
List Price:  रु20,085.75
You save:  रु5,739.19
S/336.70
List Price:  S/471.40
You save:  S/134.69
K430.39
List Price:  K602.56
You save:  K172.17
SAR375.34
List Price:  SAR525.50
You save:  SAR150.15
ZK2,295.99
List Price:  ZK3,214.48
You save:  ZK918.49
L438.46
List Price:  L613.87
You save:  L175.40
Kč2,081.70
List Price:  Kč2,914.46
You save:  Kč832.76
Ft32,846.48
List Price:  Ft45,986.39
You save:  Ft13,139.90
SEK kr945.94
List Price:  SEK kr1,324.36
You save:  SEK kr378.41
ARS$145,114.23
List Price:  ARS$203,165.73
You save:  ARS$58,051.50
Bs694.55
List Price:  Bs972.40
You save:  Bs277.84
COP$375,380.15
List Price:  COP$525,547.23
You save:  COP$150,167.07
₡49,318.20
List Price:  ₡69,047.45
You save:  ₡19,729.25
L2,637.25
List Price:  L3,692.26
You save:  L1,055
₲700,071.99
List Price:  ₲980,128.80
You save:  ₲280,056.80
$U3,927.20
List Price:  $U5,498.24
You save:  $U1,571.03
zł365.38
List Price:  zł511.55
You save:  zł146.16
Already have an account? Log In

Transcript

Hello, in this jQuery video, I am going to show you how to use the trim method. So the trim method allows you to go a bit piece of string last spring in real life, that sort of thing that you try something with strings such as characters, and it gets rid of any, you know, whitespace. So spaces on the start and the DNI inside of it doesn't start at the end. So let's create a little button from what I can do purely in JavaScript. Before I do if I create a variable called epic string, instead on say, pizza and I want to know, okay, so now if I do console dot log see what we get. It's been printed there, but it's got those empty spaces before it, okay, so if you want to get rid of them, and one use case of this could be, you have some sort of input form, that's actually what I want to do as an extra task.

Use the skills that we've learned so far to, you know, have an input forms is basic HTML, get it. So using a selector in jQuery, get that string and then apply the trim method to it. So if you have an input form, maybe it's some sort of registration form on your new amazing Facebook 2.0 social media platform. You don't want Facebook to start and at the end of the day, the username and you might let them type it in, but you'll just get rid of it. anything in between. That's different by anything that starts at the end, you don't want it so to actually get rid of this Really simple.

All strings have a method called truth over do field doctrine or whatever the string is called. And I'm just printing out directly, I could pass it to another method, a custom method of the parameter, I could assign it to a variable, whatever you want. So if I reload, as you can see, pizza is the best and this no longer has the whitespace at the start and the end. So that's it for the trim method, really simple stuff. It removes whitespace from both sides of a string, then I can change the original string, so any white space in between is left the same simple stuff. If you have any questions, feel free to pop me a message.

And as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.