This tag is for .NET/C# questions - you're probably better off asking this somewhere like SO:
https://stackoverflow.com/questions/tagged/typescript
or
https://stackoverflow.com/questions/tagged/node.js
Inserting numbers into strings in strict mode
Hi all,
I am trying to assign a file path to a variable in Typescript while in strict mode.
The path has numbers in it, particularly the date of creation prefixed.
The code is being executed in Node.JS.
This is the path:
const path = 'C:\\Software Development\\2020_12_21_NET_NodeJS\\NET_NodeJS_01';
error - [Octal escape sequences are not allowed in strict mode.]
My thought at that point was to break the string into elements of an array, then join the elements into the finished string.
const path_parts = [
'C:\\Software Development\\',
'2020_12_21_NET_NodeJS\\NET_NodeJS_01'
];
const path = path_parts.join ();
error - [Numeric separators are not allowed at the end of numeric literals]
Try again:
const path_parts = [
'C:\\Software Development',
'\\2020',
'_12', '_21_NET_NodeJS\\NET_NodeJS_01'
];
error - [Octal escape sequences are not allowed in strict mode.]
Try again:
const path_parts = [
'C:\\Software Development\\',
'2020',
'_12', '_21_NET_NodeJS\\NET_NodeJS_01'
];
error - [Unexpected number]
Try again:
const path_parts = [
'C:\\Software Development\\',
'2020',
'_', '12', '_21_NET_NodeJS\\NET_NodeJS_01'
];
error - [Unexpected number]
Remove the first element in the array, then try again:
const path_parts = [
'2020',
'_12', '_21_NET_NodeJS\\NET_NodeJS_01'
];
no error
Any help would be appreciated!
Community Center Not monitored
2 answers
Sort by: Most helpful
-
P a u l 10,761 Reputation points
2021-09-07T23:47:16.74+00:00 -
Wally96333 71 Reputation points
2021-09-08T00:10:09.503+00:00 I know,
I'm surprised that there is no tag for Typescript, or for any kind of scripts.
CSharp is the closest thing I could come up with.