http://robertdunaway.github.io
TypeScript code kata list
All code kata lists
014 TypeScript - interpolation
Duration
5 minutes
Brief
Using string interpolation
For more information
BING/GOOGLE: “TypeScript interpolation”
Instructions
Get tutorial folder or the entire katas-typescript repo.
Open the [before/*.sln]
file and execute the kata.
Feel free to execute this kata multiple times because repetition creates motor memory.
Github
- Before (start kata with this)
- After
Kata
Replace the following with an interpolated string.
var firstName: string = 'Bob';
var career: string = 'programmer';
var newString: string = firstName + ' is a ' + career + '.'
console.log('classic string concatination');
console.log(newString);
The end result might look like this.
var newInterpString: string = `${firstName} is a ${career}.`;
console.log('string interpolation');
console.log(newInterpString);
Next
Take a few minutes and imagine more examples.
0 comments:
Post a Comment