Error in variables starting with numbers

Asked 2 years ago, Updated 2 years ago, 44 views

I'd like to get a value from https://coinmarketcap.com/ja/api/, but I can't.
There is a problem with 24h_volume_usd starting with a number in the source below. Where should I fix it?

function getCoin24h_volume_usd(currency){
  // coinmarketcap API call 
  var response=UrlFetchApp.fetch("https://api.coinmarketcap.com/v1/ticker/"+currency+"/");
  var results = JSON.parse(response.getContentText()); 
  var24h_volume_usd = results[0].24h_volume_usd;
  return24h_volume_usd;
}

javascript google-apps-script

2022-09-29 22:38

1 Answers

In many programming languages, including JavaScript, the first letter of the variable name cannot contain a number (can be a second character or later).

For JavaScript

First character: half-width alphanumeric characters, underscores, dollar signs
Second and subsequent characters: half-width alphanumeric characters, underscore, dollar sign


2022-09-29 22:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.