Vscode Write Some Code
# VSCode Writing Code
VS Code has built-in support for JavaScript, TypeScript, HTML, CSS, and many other languages.
In this chapter, we will create a JavaScript code file and use some of the code editing features provided by VS Code.
VS Code supports multiple programming languages. In later chapters, we will also install (#) to add support for other languages.
### 1. Create a JavaScript File and Write Code
In the Explorer view, create a new file named app.js and enter the following JavaScript code:
## Example
function sayHello(name){
console.log('Hello, '+ name);
}
sayHello('VS Code');
**Code Auto-completion (IntelliSense):** When you start typing code, code completion suggestions will pop up. Use the β or β arrow keys to navigate through the suggestions, and press Tab to select and insert the chosen suggestion.
**Syntax Highlighting:** Notice the formatted display of the code (syntax highlighting), which helps distinguish different parts of the code and improves readability.
!(#)
### Using Code Actions
When you place the cursor on the string 'Hello,', you will see a light bulb icon, indicating that a Code Action can be applied.
You can also use the βSpace shortcut to open the light bulb menu.
Click the light bulb icon, then select Convert to template string.
!(#)
Code Actions provide quick fix suggestions for your code.
In this example, the Code Action converts the string concatenation:
"Hello, " + name
to a template string:
`Hello, ${name}`
Template strings are a special syntax in JavaScript that allows you to embed expressions within strings.
The converted code is as follows:
!(#)
YouTip