These are chat archives for FreeCodeCamp/Help

22nd
Jul 2018
Karma Drukpa
@coderkarma
Jul 22 2018 00:04
what should i pass as a parameter ?
Kyle Holm
@thekholm80
Jul 22 2018 00:06
what do you mean?
something to think about:
function outerFunc() {
  function innerFunc() {
    console.log('hello');
  }
  return innerFunc;
}

const foo = outerFunc();  // what is the value of foo?
foo();  // what happens when i do this?
Karma Drukpa
@coderkarma
Jul 22 2018 00:09
hello
foo will be hello
Kyle Holm
@thekholm80
Jul 22 2018 00:09
nope
Karma Drukpa
@coderkarma
Jul 22 2018 00:09
wait... when you called foo at the end, it will call outerfunction
Kyle Holm
@thekholm80
Jul 22 2018 00:10
the value of foo will be
function() {
  console.log('hello');
}
so when you call foo(), it will console.log('hello')
when you do something like const foo = outerFunc(); the value assigned to foo will be whatever is returned from outerFunc()
what is the return value from outerFunc()?
Karma Drukpa
@coderkarma
Jul 22 2018 00:15
innerfunc
Kyle Holm
@thekholm80
Jul 22 2018 00:15
so do you see how the example works?
Karma Drukpa
@coderkarma
Jul 22 2018 00:18
yeah so when foo() is called we will get 'hello' right , since the inner function has console.log('hello')?
Kyle Holm
@thekholm80
Jul 22 2018 00:27
yes!
so, knowing that, look at how codewars is going to use your code to decide where the parameter needs to be
Karma Drukpa
@coderkarma
Jul 22 2018 02:03
@thekholm80
function runningAverage(){
  function average(nums){
        let sum = 0;
        for (let i = 0; i <nums; i +=1){
           sum += i;
           let avg = sum /nums;
         }
  }
  return average;
}
rAvg = runningAverage();
rAvg(10);// 10.00;
still scratching my head
I am not quite sure that whether i need a loop to get avg or not?
Kyle Holm
@thekholm80
Jul 22 2018 02:06
well, yes and no. yes you'll need a loop but not in the way you're using it
right now you're looping through num times, and adding 1 to sum each loop. if that was truly your goal you could just say sum = num. but i don't think that's what you mean to do at all
sorry fixed my math, didn't notice you initialized i as 0
also, you're creating a variable inside your loop called avg but never really doing anything with it. it only exists inside your loop
Karma Drukpa
@coderkarma
Jul 22 2018 02:10
function runningAverage(){
  function average(nums){
        let sum = 0;
        for (let i = 0; i <nums; i +=1){
           sum += i;
         }
         return avg = sum/nums;
  }
  return average;
}
rAvg = runningAverage();
rAvg(10);// 10.00;
my biggest confusion is, I am not sure to get average with doing for loops and passing nums as a parameter.
Kyle Holm
@thekholm80
Jul 22 2018 02:12
so when your inner function gets called you'll get an error saying it doesn't know what avg is. also, you should generally avoid assignment in a return statement
one thing i think you're missing is nums will only be a single number. you have to have a way to remember which numbers have been passed into your inner function, so you can use them the next time the inner function gets called
Karma Drukpa
@coderkarma
Jul 22 2018 02:32
hmm......
Alexander R Bott
@Abott1222
Jul 22 2018 02:41
that video was aweful
this one looks better
there is too much content on youtube.
Kyle Holm
@thekholm80
Jul 22 2018 02:42
lol
Aditya
@ezioda004
Jul 22 2018 03:08
@thekholm80 Interesting, didnt know python only supported half closures.
Kyle Holm
@thekholm80
Jul 22 2018 03:11
@ezioda004 i don't know that term
but learning about global, nonlocal and all that was cool
Aditya
@ezioda004
Jul 22 2018 03:14

@thekholm80 Half closure as in that the closure variable is "read" only.

def addX(x):
    x+=1
    def addY(y):       
        return x + y
    return addY
y = addX(1)
print(y(2)) //4
print(y(2)) //4

y(2) keeps returning 4, where as in other languages it'd increment.

Kyle Holm
@thekholm80
Jul 22 2018 03:14
i see
it was a lot of reading trying to figure out how to modify outer function's variables
found 2 ways though, both seemed pretty useful
Aditya
@ezioda004
Jul 22 2018 03:16
How? I think nonlocal helps in this?
Kyle Holm
@thekholm80
Jul 22 2018 03:17
that was the way i preferred, but you can also
def outer():
  outer.a = 1
  def inner():
    b = 1 + outer.a
Aditya
@ezioda004
Jul 22 2018 03:18
Thats clever.
Kyle Holm
@thekholm80
Jul 22 2018 03:19
i think that would be more useful if you have to nest several levels deep. i think it would make it easier to keep track of everything
manarsalah
@manarsalah
Jul 22 2018 03:19
hi
Kyle Holm
@thekholm80
Jul 22 2018 03:19
@manarsalah :wave:
manarsalah
@manarsalah
Jul 22 2018 03:20
I am stuck at the freecodecamp challenge (Specify How Fonts Should Degrade)
Kyle Holm
@thekholm80
Jul 22 2018 03:22
what have you tried?
manarsalah
@manarsalah
Jul 22 2018 03:23

h2 {
font-family: Lobster,moonspace;
}

p {
font-size: 16px;
font-family: monospace;
}
</style>
<!--"lobster degrades to moonspace"-->

<h2 class="red-text">CatPhotoApp</h2>

Kyle Holm
@thekholm80
Jul 22 2018 03:23
font-family: Lobster,moonspace; check your spelling
manarsalah
@manarsalah
Jul 22 2018 03:24
yes
haha would have been stuck for million years
thanks @thekholm80
Kyle Holm
@thekholm80
Jul 22 2018 03:25
:+1:
Aditya
@ezioda004
Jul 22 2018 03:33
@thekholm80 Did you solve that kata in JS? The rounding seems super weird.
Kyle Holm
@thekholm80
Jul 22 2018 03:35
i did
i used Math.round()
Aditya
@ezioda004
Jul 22 2018 03:36
Err I used .toFixed(2), sometimes it passes all the test other times its failing 1 random test by 0.01.
Kyle Holm
@thekholm80
Jul 22 2018 03:37
i tried that first, but i was getting 10.00 and 10.50
which the tests didn't like
Aditya
@ezioda004
Jul 22 2018 03:40
Saw your solution, I have similar solution too. You can also make it one line by using &&.
return history.push(num) && Math.round((history.reduce((a, b) => a + b) / history.length) * 100) / 100;
Karma Drukpa
@coderkarma
Jul 22 2018 03:40
@thekholm80 i still couldn't solve it kyle
@thekholm80 trying other way without loop
Kyle Holm
@thekholm80
Jul 22 2018 03:42
okay
@ezioda004 that's ugly lol
Aditya
@ezioda004
Jul 22 2018 03:43
Must.Make.It.1.Liner
Kyle Holm
@thekholm80
Jul 22 2018 03:44
hahaha
i saw someone doing a bunch of var x; var y; x = y + 1; kind of crap to make a one liner
seemed kind of cheating
Aditya
@ezioda004
Jul 22 2018 03:45
Yeah, thats cheating, wheres mah pitchfork!
Lets get that guy ⎯⎯∈
Kyle Holm
@thekholm80
Jul 22 2018 03:46
lol
Karma Drukpa
@coderkarma
Jul 22 2018 05:46
@thekholm80 @ezioda004
I am kind of confuse to make check whether character is repeated or not or in a string
let's say string is "abacabad"
i was trying to make check this way but i felt it will not work if i do , string[i] === string[i + 1]
Aditya
@ezioda004
Jul 22 2018 06:01
@coderkarma That'll only check for the consecutive.
One way would be checking for .indexOf() and .lastIndexOf()
str.indexOf(str[i]) === str.lastIndexOf(str[i]) //if true then no repetition
Karma Drukpa
@coderkarma
Jul 22 2018 06:03
Oh!! so if we do that no repetition, nice. didn't thought of this
cool
Thanks man
i was just doing random codeflight simple challenge let me try with that way
Aditya
@ezioda004
Jul 22 2018 06:07
@coderkarma Its not very effective though, since indexOf and lastIndexOf are loop themselves, so thats like 3 loops including the original string loop.
A better way would be looping through the string once and creating an object and checking.
let string = "abacabad";
let strObj = {};
for (let i = 0; i < string.length; i++){
  if (!strObj[string[i]]){ //checking if that char prop exists in the strObj
    strObj[string[i]] = 1; //initializing
  }
  else {
    //duplicate found, do something with it
  }
}
Manish Giri
@Manish-Giri
Jul 22 2018 06:11
@coderkarma To verify if there is even one repetition of any character, you can create a Set object out of the given string, and see if there's any difference between the size of the set object and length of the string.
If the Set object has a lesser size, then there are duplicates.
Karma Drukpa
@coderkarma
Jul 22 2018 06:12
oh nice @ezioda004 didn't realize we could we object as well. i only used object for counting the letters
@Manish-Giri I am not quite comfortable with set object. thanks though, i will mdn that.
Manish Giri
@Manish-Giri
Jul 22 2018 06:15
It's just new Set(string)
either way, MDN's helpful..
Karma Drukpa
@coderkarma
Jul 22 2018 06:17
function firstNotRepeatingCharacter(s) {
 for (let i = 0; i < s.length; i += 1){
    let char = s[i];
    if (s.indexOf(s[i])  === s.lastIndexOf(s[i])){
      return char
    } 
  }
  return '-';
}
will try with obj now
Smootimus
@Smootimus
Jul 22 2018 13:50
Would be better as Non :P
Adegoke Fred
@Frediflexta
Jul 22 2018 14:09
Hi guys..
Spur
@Spur_Gaming_twitter
Jul 22 2018 14:09
hey
Adegoke Fred
@Frediflexta
Jul 22 2018 14:10
I am experiencing a bug, so i'm trying to write a function that checks the strength of passwords
function checkPassword(password) {
  password = '';
  // console.log(password);

  let total = 0;

  // regex for lowercase alphabets
  let lowercase = new RegExp('^(?=.*[a-z])$');

  // regex for uppercase alphaets
  let uppercase = new RegExp('^(?=.*[A-Z])$');

  // regex for numbers
  let numbers = new RegExp('^(?=.*\d)$');

  // regex for none alphanumeric characters
  let specialcase = new RegExp('^(?=.*[!@#$%^&*])$');

  // regex for for all of the above
  let strongPwd = new RegExp('^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]$');

  if (lowercase.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  } else if (uppercase.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  } else if (numbers.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  } else if (specialcase.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  } else if (strongPwd.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  }
}

console.log(checkPassword('Mandela'));
Nazar
@IsaakNazar
Jul 22 2018 14:11
hey everybody, does anyone have experience with emberJs? I get through official tutorial, but understand only the first half, pretty hard to understand
Adegoke Fred
@Frediflexta
Jul 22 2018 14:11
When I run the code in node, i get undefined
like i'm not parsing my parameter correctly, but i can't see what i am doing wrong, help please
Kyle Holm
@thekholm80
Jul 22 2018 14:12
@Frediflexta looks like someone passes in a password and the first thing you do is set it to an empty string password = '';
Moisés Man
@moigithub
Jul 22 2018 14:12
soo none of ur returns are executed... (implicit return = undefined) @Frediflexta
add a else case
Adegoke Fred
@Frediflexta
Jul 22 2018 14:13
Okay, but even if i don't have that line, it still returns undefined
Kyle Holm
@thekholm80
Jul 22 2018 14:14
read what @moigithub wrote
Adegoke Fred
@Frediflexta
Jul 22 2018 14:15
oh..
Moisés Man
@moigithub
Jul 22 2018 14:17
what this means ??
?=.*
Spur
@Spur_Gaming_twitter
Jul 22 2018 14:24
Hey kyle
Kyle Holm
@thekholm80
Jul 22 2018 14:25
:wave:
Adegoke Fred
@Frediflexta
Jul 22 2018 14:31
what this means ??
?=.* it means positive lookahead, match a group and expect characters except a linebreak and check all strings
From the lil i understand about Regex
Kyle Holm
@thekholm80
Jul 22 2018 14:34
oh man, the 2018 JS release includes regex lookbehinds
and named capture groups
May Kittens Devour Your Soul
@diomed
Jul 22 2018 15:26
@thekholm80 what that means in plain English?
Kyle Holm
@thekholm80
Jul 22 2018 15:27
it means the JS regex engine is going to have some functionality that the rest of the programming world has had for a long time
May Kittens Devour Your Soul
@diomed
Jul 22 2018 15:27
oh , Js catching up to programming world. welp, that's nice, I guess
Moisés Man
@moigithub
Jul 22 2018 16:19
ES9 feature .. i didnt finish to learn es6 yet
Anand Potukuchi
@anandpotukchi
Jul 22 2018 16:31
hi
can anyone hlp me pout with this challenge please
this is the iniitlal code
<style>
  .item1 {
    background: LightSkyBlue;
    grid-area: header;
  }

  .item2 {
    background: LightSalmon;
    grid-area: advert;
  }

  .item3 {
    background: PaleTurquoise;
    grid-area: content;
  }

  .item4 {
    background: lightpink;
    grid-area: footer;
  }

  .container {
    font-size: 1.5em;
    min-height: 300px;
    width: 100%;
    background: LightGray;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 50px auto 1fr auto;
    grid-gap: 10px;
    grid-template-areas:
      "header"
      "advert"
      "content"
      "footer";
  }

  @media (min-width: 300px){
    .container{
      grid-template-columns: auto 1fr;
      grid-template-rows: auto 1fr auto;
      grid-template-areas:
        "advert header"
        "advert content"
        "advert footer";
    }
  }

  @media (min-width: 400px){
    .container{
      /* change the code below this line */

      grid-template-areas:
        "advert header"
        "advert content"
        "advert footer";

    /* change the code above this line */
    }
  }
</style>

<div class="container">
  <div class="item1">header</div>
  <div class="item2">advert</div>
  <div class="item3">content</div>
  <div class="item4">footer</div>
</div>
I've tried emoving advert in the header amd footer sections 400px qiuery
doesn;t seem to be working
Anand Potukuchi
@anandpotukchi
Jul 22 2018 16:37
maybe i didn't understand the templates properly
Moisés Man
@moigithub
Jul 22 2018 16:37
its not only remove.. its replacing... all cells need to have something
if u have 2 cols + 3 rows.. that make a 6 cells total
soo if u want all ur cells filled with footer content.. u should do something like
 grid-template-areas:
        "footer footer"
        "footer footer"
        "footer footer";
Anand Potukuchi
@anandpotukchi
Jul 22 2018 16:39
oh thanks @moigithub
So with this I've competed the challenges
need to do the projects
good night
let's meet tomorrow
Adegoke Fred
@Frediflexta
Jul 22 2018 16:44
Hey guys, so I am still haven't been able to figure out where I am making a mistake from, please can someone help unblock me?
function checkPassword(password) {
  let total = 0;

  // regex for lowercase alphabets
  let lowercase = new RegExp('^(?=.*[a-z])$');

  // regex for uppercase alphaets
  let uppercase = new RegExp('^(?=.*[A-Z])$');

  // regex for numbers
  let numbers = new RegExp('^(?=\d)$');

  // regex for none alphanumeric characters
  let specialcase = new RegExp('^(?=.*[!@#$%^&*])$');

  // regex for for all of the above
  let strongPwd = new RegExp('^(?=\d)(?=.*[!@#$%^&*])[a-zA-Z!@#$%^&*]$');

  if (lowercase.test(password)) {
    console.log(password);
    total += 25;
    return `Your Password strength is ${total}`;
  }  else if (uppercase.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  }  else if (numbers.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  }  else if (specialcase.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  }  else if (strongPwd.test(password)) {
    total += 25;
    return `Your Password strength is ${total}`;
  } else return 'Provide a password';
}

console.log(checkPassword('Mandela'));
It's a function that is suppose to check the strength of a password, when i run the code, it just returns Provide a password, The code in the if statements don't get run
Kyle Holm
@thekholm80
Jul 22 2018 16:46
that means none of your regex tests are returning true
i'd figure out what your expected behavior is, then start logging actual results to figure out why you're not getting your expected behavior
debugging is fun
Moisés Man
@moigithub
Jul 22 2018 16:49
what this check should do ??
// regex for lowercase alphabets
let lowercase = new RegExp('^(?=.*[a-z])$');
to have ONLY lowercase ? or at least some lowercase characters ? @Frediflexta
cuz usually strong pwd have a combination of all those rules
Adegoke Fred
@Frediflexta
Jul 22 2018 16:50
to have at least one lowercase
Yea, so I want to check to see if there is also a string that has all 4 cases
special characters, lowercase, uppercase and numbers
Nazar
@IsaakNazar
Jul 22 2018 16:56
it seems, using javascript frameworks doesnt boost my argorithmic thinking skills improved through codewars challenges :(
do you devote your time to argorithm challenges?
Kyle Holm
@thekholm80
Jul 22 2018 16:59
@IsaakNazar i can't recall if learning react helped me that way or not. i still do a lot of codewars to keep thinking outside the box
seems almost like react did a lot of the hard thinking for me, and everything became more "fill-in-the-blank" instead of problem solving
or formulaic, at least
Moisés Man
@moigithub
Jul 22 2018 17:01

probably u want to remove ^ and $
if u have something like this /^[a-z]*$/ it can be readed as.. from start to the end.. it should have only this set of characters [a-z].. so if u have anything else it will fail

/^[a-z]*$/.test("aa")
true
/^[a-z]*$/.test("aaA")
false

@Frediflexta

Nazar
@IsaakNazar
Jul 22 2018 17:01
@thekholm80 its very sad, we are all in the same boat :(
Kyle Holm
@thekholm80
Jul 22 2018 17:01
@IsaakNazar doing back end seems more challenging that way for me
Nazar
@IsaakNazar
Jul 22 2018 17:02
@thekholm80 no matter what language? Python, Node
Kyle Holm
@thekholm80
Jul 22 2018 17:02
yep
Adegoke Fred
@Frediflexta
Jul 22 2018 17:03
@moigithub Okay, lemme try that
Kyle Holm
@thekholm80
Jul 22 2018 17:03
but there are a lot of tools that simplify the back end, too. django for python, express, passport, etc for node
Nazar
@IsaakNazar
Jul 22 2018 17:04
@thekholm80 and the only rescue is codewars :)
Kyle Holm
@thekholm80
Jul 22 2018 17:04
haha yeah
Nazar
@IsaakNazar
Jul 22 2018 17:07
@thekholm80 what about machine learning, AI ? same?
Kyle Holm
@thekholm80
Jul 22 2018 17:07
oh god no
get you some tensorflow.js, play with it
or just tensorflow if you like python
Nazar
@IsaakNazar
Jul 22 2018 17:08
tell me your impressions about tensorflow
Kyle Holm
@thekholm80
Jul 22 2018 17:09
i've never actually used it, but i've watched / read a lot about it. it does a good job of taking an enormous amount of data, studying it, then making predictions / decisions based on everything it has learned
the concept is fairly simple, but some most of the stuff people are doing with it is way over my head
Nazar
@IsaakNazar
Jul 22 2018 17:16
@thekholm80 in other words tensorflow gives you tons of algorithmic challenges? if yes, I definitely will study it :)
Kyle Holm
@thekholm80
Jul 22 2018 17:16
it does
Nazar
@IsaakNazar
Jul 22 2018 17:17
Great :thumbsup: @thekholm80
Kyle Holm
@thekholm80
Jul 22 2018 17:17
from what i've seen, just cleaning/normalizing all the training data is an enormous challenge
Nazar
@IsaakNazar
Jul 22 2018 17:18
@thekholm80 no matter tensorflow.js or python tensorflow?
Kyle Holm
@thekholm80
Jul 22 2018 17:18
i believe so
@IsaakNazar this was done with tensorflow.js
this was done with tensorflow
Adegoke Fred
@Frediflexta
Jul 22 2018 17:24
@moigithub Thanks Your suggestion unblocked me, I also found out 2 of my regex where not correct
Manuel Grondona
@manuel-grondona
Jul 22 2018 17:24
Hello!! Is there anyone with some chrome extensions knowledge?
Nazar
@IsaakNazar
Jul 22 2018 17:26
@thekholm80 thx for links, amazing :thumbsup:
Kyle Holm
@thekholm80
Jul 22 2018 17:27
@manuel-grondona i've built a simple extension, but i'm no expert
@IsaakNazar the guy on youtube also played mario with tensorflow. that was a cool video too
Manuel Grondona
@manuel-grondona
Jul 22 2018 17:30
@thekholm80 Hi Kyle! maybe you can help me, for some reason the quality of the rendering changes when I load my extension locally from when I do the whole load unpacked and try the extension (sorry about my english, not my native language clearly). Basically, the same html looks different when I try it after loading it to chrome extensions
I checked and there are no errors, the css files load ok, and everything looks fine
Kyle Holm
@thekholm80
Jul 22 2018 17:31
that's really strange
i really don't know what the problem could be. i never bothered to publish mine to the chrome web store, so i'm not familiar with anything that happens after development
Manuel Grondona
@manuel-grondona
Jul 22 2018 17:36
ok, no problem! I'll keep researching about it
thank you!
Spur
@Spur_Gaming_twitter
Jul 22 2018 18:57
@thekholm80
Kyle Holm
@thekholm80
Jul 22 2018 19:00
?
Spur
@Spur_Gaming_twitter
Jul 22 2018 19:01
Ops
sorry
idk how to this question The type attribute selector should be used to select the checkboxes.
Kyle Holm
@thekholm80
Jul 22 2018 19:01
how do you think it should be done?
Spur
@Spur_Gaming_twitter
Jul 22 2018 19:02
image.png
Kyle Holm
@thekholm80
Jul 22 2018 19:02
is there a reason your type is radio?
Spur
@Spur_Gaming_twitter
Jul 22 2018 19:03
It had a expamle so i did the same
Kyle Holm
@thekholm80
Jul 22 2018 19:04
but you don't want to select radio buttons
Spur
@Spur_Gaming_twitter
Jul 22 2018 19:05
Checkboxes
Kyle Holm
@thekholm80
Jul 22 2018 19:05
right
Spur
@Spur_Gaming_twitter
Jul 22 2018 19:06
I changed "radio to checkboxes but it didn't give me a green check
image.png
Kyle Holm
@thekholm80
Jul 22 2018 19:07
much like they used radio instead of radios you don't want plural checkboxes
the type should match the element type
Spur
@Spur_Gaming_twitter
Jul 22 2018 19:07
Ohh
Kyle Holm
@thekholm80
Jul 22 2018 19:07
<label><input type="checkbox" name="personality" checked> Loving</label> it doesn't say checkboxes
Spur
@Spur_Gaming_twitter
Jul 22 2018 19:07
It's CHeck box
CheckBox
Checkbox
Thanks
May Kittens Devour Your Soul
@diomed
Jul 22 2018 19:28
heckBox
Karma Drukpa
@coderkarma
Jul 22 2018 21:56
@thekholm80
Kyle Holm
@thekholm80
Jul 22 2018 21:58
?
Karma Drukpa
@coderkarma
Jul 22 2018 22:02
Here, you try. Change the greeting string below to use a template literal. Also, feel free to swap in your name for the placeholder.


/*
 * Instructions: Change the `greeting` string to use a template literal.
 */

const myName = `${'karma'}`;
const greeting = `'Hello, my name is ${myName}'`;
console.log(greeting);



Kyle Holm
@thekholm80
Jul 22 2018 22:03
you don't need the single quotes inside your template literal, unless you want the text to appear in single quotes
`'hello'` is 'hello'
yikes, that doesn't format well lol
the other thing is your variable doesn't need the ${ }
const myName = 'karma';
Karma Drukpa
@coderkarma
Jul 22 2018 22:14
so i don't need to put back tick at the beginning of my hello
Kyle Holm
@thekholm80
Jul 22 2018 22:15
i'm saying you probably don't need the single quotes
const myString = `This is a template literal`
Karma Drukpa
@coderkarma
Jul 22 2018 22:16
ok
const myName = 'karma';
const greeting = `Hello, my name is  ${myName}`;
console.log(greeting);
Kyle Holm
@thekholm80
Jul 22 2018 22:17
there you go
got lots of spaces after name is but that's the general idea
Karma Drukpa
@coderkarma
Jul 22 2018 22:20
ok thanks. but they want me to change the greeting with template literal which i believe i did. but let me sent you default question
/*
 * Instructions: Change the `greeting` string to use a template literal.
 */

const myName = '[NAME]';
const greeting = 'Hello, my name is ' + myName;
console.log(greeting)
Here, you try. Change the greeting string below to use a template literal. Also, feel free to swap in your name for the placeholder.
Kyle Holm
@thekholm80
Jul 22 2018 22:22
did you remove the extra space?
Karma Drukpa
@coderkarma
Jul 22 2018 22:23
oh yes, it was space problem lol
thanks super man
Kyle Holm
@thekholm80
Jul 22 2018 22:23
a big part of writing code is attention to detail
Karma Drukpa
@coderkarma
Jul 22 2018 22:26
so whenever we use the template literal, we must use ${} . either whole string or single word right
Kyle Holm
@thekholm80
Jul 22 2018 22:27
you only use ${} to insert values from variables or expressions into template literals
Karma Drukpa
@coderkarma
Jul 22 2018 22:27
not need of back tick then?
Kyle Holm
@thekholm80
Jul 22 2018 22:27
no, then you could just use a normal string
const string = '1 + 1 = 2';
const literal = `1 + 1 = ${ 1 + 1 }`;
const a = 2;
const anotherLiteral = `1 + 1 = ${ a }`;
these will have the same value
Karma Drukpa
@coderkarma
Jul 22 2018 22:30
oh!!!
const cheetah = {
    name: 'Cheetah',
    scientificName: 'Acinonyx jubatus',
    lifespan: '10-12 years',
    speed: '68-75 mph',
    diet: 'carnivore',
    summary: 'Fastest mammal on land, the cheetah can reach speeds of 60 or perhaps even 70 miles (97 or 113 kilometers) an hour over short distances. It usually chases its prey at only about half that speed, however. After a chase, a cheetah needs half an hour to catch its breath before it can eat.',
    fact: 'Cheetahs have “tear marks” that run from the inside corners of their eyes down to the outside edges of their mouth.'
};
so if i want to write template literal like animal diet,
Karma Drukpa
@coderkarma
Jul 22 2018 22:37
can I write this way like ${cheetah.diet} to extract the information of cheetah diet. we can use object principle in template literal
Kyle Holm
@thekholm80
Jul 22 2018 22:37
yep