JavaScript How would I combine these 2 similar functions?

I have created two functions that run a similar set of IF statements, one shows the cost of a game, the other its name. I have used "onclick" to display both values in my form. It all works but suffers from bloat. Is there a way to combine both functions to shorten the script?

        function GameTitle() {
var textboxValue = document.getElementById("game_id").value;
    var message;
    if (textboxValue == 1) {
        message = "Fantasy World";
    } else if (textboxValue == 2) {
        message = "Sir Wags A Lot";
    } else if (textboxValue == 3) {
        message = "Take a Path";
    } else if (textboxValue == 4) {
        message = "River Clean Up";
    } else if (textboxValue == 5) {
        message = "PinBall";
    } else if (textboxValue == 6) {
        message = "Ghost girl";
    } else if (textboxValue == 7) {
        message = "Dress Up";
    } else if (textboxValue == 8) {
        message = "Where is my hat?";
    } else {
        message = "Invalid ID";
    }
document.getElementById("game_title").value = message;
}

//Display price of Game
    function Cost() {
var textboxValue = document.getElementById("game_id").value;
    var cost;
    if (textboxValue == 1) {
        cost = "0.99";
    } else if (textboxValue == 2) {
        cost = "0.99";
    } else if (textboxValue == 3) {
        cost = "1.99";
    } else if (textboxValue == 4) {
        cost = "1.99";
    } else if (textboxValue == 5) {
        cost = "3.99";
    } else if (textboxValue == 6) {
        cost = "3.99";
    } else if (textboxValue == 7) {
        cost = "1.99";
    } else if (textboxValue == 8) {
        cost = "1.99";
    } else {
        cost = "Invalid ID";
    }
document.getElementById("cost").value = cost;
}
Answer:1

I'm new to Mocha and I'm trying to run the tests on this code: "use strict"; process.env.NODE_ENV = 'test'; var assert = require('assert'), Browser = require('zombie'), xapp = require('../...

I'm new to Mocha and I'm trying to run the tests on this code: "use strict"; process.env.NODE_ENV = 'test'; var assert = require('assert'), Browser = require('zombie'), xapp = require('../...

I've been trying to push a complex json data record into a json variable. This is the code I tried to do so. var marks=[]; var studentData="student1":[{ "term1":[ {"LifeSkills":[{...

I've been trying to push a complex json data record into a json variable. This is the code I tried to do so. var marks=[]; var studentData="student1":[{ "term1":[ {"LifeSkills":[{...

Can I center the content of div with center-block?? The following example does not work: <div class="form-group"> <div class="center-block"> <input id="...

Can I center the content of div with center-block?? The following example does not work: <div class="form-group"> <div class="center-block"> <input id="...

  1. center content with flexbox
  2. center content with css
  3. center content with flex
  4. center content with padding
  5. center content with bootstrap
  6. center content with margin
  7. center content with css grid
  8. flexbox center content
  9. center content with html
  10. center content in div
  11. center content in div bootstrap
  12. center content in div css
  13. center content in div vertically
  14. center content in div bootstrap 4
  15. center content in column bootstrap
  16. center content in td
  17. center content in column bootstrap 4
  18. center content in table cell
  19. center content in div horizontally
  20. center content in row bootstrap 4

I have the following array: var data= [{ "Id": 1, "Name": "NameOne"} { "Id": 2, "Name": "NameTwo"} { "Id": 2, "Name": "NameTwo"}] { "Id": 3, "Name": "NameThree"}] ...

I have the following array: var data= [{ "Id": 1, "Name": "NameOne"} { "Id": 2, "Name": "NameTwo"} { "Id": 2, "Name": "NameTwo"}] { "Id": 3, "Name": "NameThree"}] ...

  1. linq group with join
  2. linq group with count
  3. linq group with sum
  4. linq group with where
  5. linq group with where clause
  6. linq with group by c#
  7. linq group to dictionary
  8. linq group to list
  9. linq group having
  10. linq group and order by
  11. linq group and select
  12. linq group and sort
  13. linq group having count
  14. linq group and count c#
  15. linq group and sum list
  16. linq group and select first
  17. linq group and max
  18. linq group and sum c#
  19. linq group to array
  20. linq group and aggregate