Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Abhishek Kumar
@Mr-Kumar-Abhishek
@callumquick $(".text-center").addClass("searched"); is not working ~
Jacob
@jdc101214
Hey guys.
Why is this code not working?
function truncateString(str, num) {
  // Clear out that junk in your trunk

  return str.slice(0, num) + "...";
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Abhishek Kumar
@Mr-Kumar-Abhishek
@callumquick yes
Callum Ward
@callumquick
@Mr-Kumar-Abhishek Really? You're applying that in the result_display function?
Abhishek Kumar
@Mr-Kumar-Abhishek
@callumquick yes
Callum Ward
@callumquick
@Mr-Kumar-Abhishek Try making a more specific selector by giving it an ID like #content and then calling $("div.text-center#content")
Abhishek Kumar
@Mr-Kumar-Abhishek
@callumquick thanks :) I am trying it
CamperBot
@camperbot
mr-kumar-abhishek sends brownie points to @callumquick :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @callumquick |http://www.freecodecamp.com/callumquick
Callum Ward
@callumquick
@jdc101214 It works for some of the case but you'll need some conditionals for special cases, for example if the string length is shorter than num then your "..." is being applied anyway which you don't want.
@jdc101214 Try some console.log()s to see what is being outputted, this helps greatly with debugging.
@jdc101214 For almost all the algorithms, what you think will happen won't happen, and only by seeing what does happen can you find the bug in your code.
Jacob
@jdc101214
@callumquick Thanks for the help, but the consol.log doesnt work on the lessons.
CamperBot
@camperbot
jdc101214 sends brownie points to @callumquick :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @callumquick |http://www.freecodecamp.com/callumquick
Abhishek Kumar
@Mr-Kumar-Abhishek
@callumquick it worked :D thanks
CamperBot
@camperbot
mr-kumar-abhishek sends brownie points to @callumquick :sparkles: :thumbsup: :sparkles:
:warning: mr-kumar-abhishek already gave callumquick points
Jacob
@jdc101214
Ive tried so many times....
Callum Ward
@callumquick
@jdc101214 It does, it says it gets outputted to the little black box there, but it doesn't, right? But it still does get outputted in the Javascript developer console. Press CTRL-SHIFT-J while on the lesson and clear away the error messages, then ctrl-enter run your code again with some console.log()s, they show up in the console.
Jacob
@jdc101214
ok.
Let me try that
Callum Ward
@callumquick
@Mr-Kumar-Abhishek Welcome
Jacob
@jdc101214
function truncateString(str, num) {
  // Clear out that junk in your trunk
  var str1 = "";
  if(str.length > num){
  return str.slice(0, num - 3) + "...";
} if(str.length < num) {
  str1 = str.slice(0, num + num) + "...";
  return str1;
}
  if (num <= 3) {
    return str.slice(0, num + num) + "...";
  }
console.log(str1);

}

truncateString("Absolutley", 2);
Why is this not working?
Callum Ward
@callumquick
@jdc101214 Why str.slice(0, num + num)?
num+num will just return 2*num
Jacob
@jdc101214
right. I did that bec truncateString("A-", 1) should equal "A..." ANd that was how I got that to work.
Callum Ward
@callumquick
@jdc101214 Maybe you should remove all non-alphabetic characters with a RegExp test?
Actually no, sorry, that's not what you want
What you want is that if str.length<3 you just cut it to num long and tack "..." on the end
I.e. don't cut it to num-3 to squeeze in the extra "...", this is what the description says you should do if the string is shorter than 3 characters
Jacob
@jdc101214
Ok, I think Im completely confused about this challenge...
Callum Ward
@callumquick

Also, I don't understand what purpose

if (num <= 3) {
    return str.slice(0, num + num) + "...";
  }

is serving?

Jacob Jackson
@bearswamppastor

Can someone help me understand how to insert an image using bootstrap? <img src="test.jpg" style:"width:100%">

That is the code I'm using, but it only gets me a broken image and it's small and in the left hand corner of the screen.

Callum Ward
@callumquick
@bearswamppastor Which challenge?
@bearswamppastor Putting in the img is the same in bootstrap, bootstrap just offers classes to make it look prettier
@jdc101214 Maybe it is best if you comment out what you already have, and start again from scratch thinking about what you need to do
Jacob
@jdc101214
ok will do.
ok, i figured it out. thanks
@callumquick thanks
CamperBot
@camperbot
jdc101214 sends brownie points to @callumquick :sparkles: :thumbsup: :sparkles:
:warning: jdc101214 already gave callumquick points
Callum Ward
@callumquick
@jdc101214 No problem :)
Jacob Jackson
@bearswamppastor
@callumquick It's the first challenge that you do on your own without the guides. Making a tribute page.
Callum Ward
@callumquick
@bearswamppastor Ah ok, on codepen.io you have to make sure to include your own dependencies, have you added the bootsrap URL in the Settings>CSS part of the interface?
Jacob Jackson
@bearswamppastor
@callumquick Yes, I added bootstrap in the CSS settings.
@callumquick The image is on my computer. Does it need to be online?
Callum Ward
@callumquick
@bearswamppastor I think it does, for codepen to be able to access it
GabriRa
@GabriRa
Thanks @JLuboff
CamperBot
@camperbot
gabrira sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles: