Просмотр исходного кода

Finish Template Strings

Signed-off-by: Michael Tang <michael.h.tang@gmail.com>
Michael Tang 5 лет назад
Родитель
Сommit
9dc4a50a99
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      arguments.js

+ 7 - 2
arguments.js

@@ -19,11 +19,16 @@ console.log(scoreText)
 
 let calculateTip = function (total, tipPercent = 0.2) {
     let tip = total * tipPercent
-    return tipPercent * 100 + '% Tip on $' + total + ' is $' + tip
+    // return tipPercent * 100 + '% Tip on $' + total + ' is $' + tip
+    return `A ${tipPercent * 100}% tip on $${total} would be $${tip}.`
 }
 
 let tip = calculateTip(100)
 console.log(tip)
 
 let tip2 = calculateTip(100, 0.15)
-console.log(tip2)
+console.log(tip2)
+
+let name = 'Vikram'
+let age = 1.5
+console.log(`Hey, my name is ${name}! I am ${age} years old`)