let {a, b} = {a: 'Hello ', b: 'Jack'}; console.log(a.length) y is this code giving me 6 while i thought it's 5 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

let {a, b} = {a: 'Hello ', b: 'Jack'}; console.log(a.length) y is this code giving me 6 while i thought it's 5

Lenght

9th Jul 2019, 1:03 PM
SAMMY.
SAMMY. - avatar
6 Answers
+ 5
As I see you have a blank space after "o" in "Hello". Remove it and the length will be 5.
9th Jul 2019, 1:08 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 15
There is a space after o. WhiteSpace " " is considered as a character in almost all general propose programming languages in the World.
9th Jul 2019, 2:28 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 3
there is a space after o
9th Jul 2019, 1:07 PM
Gordon
Gordon - avatar
+ 2
I believe it has a space at the end, so it gives 6
9th Jul 2019, 1:08 PM
Payton Zhong
Payton Zhong - avatar
+ 2
Or you can probably do this: a.trim(); before it logs it to the console
24th Aug 2019, 12:04 AM
Rishan [da_coder, semi-active]
Rishan  [da_coder, semi-active] - avatar
+ 1
Remove the space at the end of 'Hello '
9th Jul 2019, 4:46 PM
Rᴀ.Oɴᴇ
Rᴀ.Oɴᴇ - avatar