I just wanted to know how can I code more efficiently with my project. I'm pretty sure that all these nested if's can be done easier and with less code.I made a TicTacToe game with 3 difficulty levels. Easy, Medium and Hard. The Easy level you have 3X3 table, Medium: 4X4 table & Hard: 5X5 table. As you can see I made the game tables with jQuery. All the else-if are the CPU moves. I was wondering how can i write less code. The randomMove1 function is the CPU move so it places the O's on the game table.$(document).ready(function () {                var x = X,                    o = O,                    move = 0,                    score = 0,                    random1 = Math.floor(Math.random() * 10),                    random2 = Math.floor(Math.random() * 20);                // $(.container).hide();                $(#again).attr(disabled, disabled);                $(#score).hide();                // $(#buttonStart).click(function(){                $(.container).show();                $(#buttonStart).hide();                $(img).hide();                //  })                $(#new).click(function StartGame() { // tabelen maken                            $(#score).fadeIn(100);                            if ($(#easy).prop(checked) && $(#medium).prop(checked, false)) {                                $(#bord1).append(<table1></table1>);                                var table1 = $(#bord1).children();                                table1.append(<tr><td id='t1td1'></td><td id='t1td2'></td><td id='t1td3'></td></tr>);                                table1.append(<tr><td id='t1td4'></td><td id='t1td5'></td><td id='t1td6'></td></tr>);                                table1.append(<tr><td id='t1td7'></td><td id='t1td8'></td><td id='t1td9'></td></tr>);                                $(#bord1).fadeIn(slow);                                $(#bord2).empty();                                $(#bord3).empty();                            } else { // BEGIN VAN DE GROTE ELSE                                if ($(#easy).prop(checked, false) && $(#medium).prop(checked)) {                                    $(#bord2).append(<table2></table2>);                                    var table2 = $(#bord2).children();                                    table2.append(<tr><td id='t2td1'></td><td id='t2td2'></td><td id='t2td3'></td><td id='t2td4'></td></tr>);                                    table2.append(<tr><td id='t2td5'></td><td id='t2td6'></td><td id='t2td7'></td><td id='t2td8'></td></tr>);                                    table2.append(<tr><td id='t2td9'></td><td id='t2td10'></td><td id='t2td11'></td><td id='t2td12'></td></tr>);                                    table2.append(<tr><td id='t2td13'></td><td id='t2td14'></td><td id='t2td15'></td><td id='t2td16'></td></tr>);                                    $(#bord2).fadeIn(slow);                                    $(#bord1).empty();                                    $(#bord3).empty();                                } else {                                    $(#new).prop(disabled, false);                                    if ($(#hard).prop(checked) && $(#easy).prop(checked, false) && $(#medium).prop(checked, false)) {                                        $(#bord3).append(<table3></table3>);                                        var table3 = $(#bord3).children();                                        table3.append(<tr><td id='t3td1'></td><td id='t3td2'></td><td id='t3td3'></td><td id='t3td4'></td><td id='t3td5'></td></tr>);                                        table3.append(<tr><td id='t3td6'></td><td id='t3td7'></td><td id='t3td8'></td><td id='t3td9'></td><td id='t3td10'></td></tr>);                                        table3.append(<tr><td id='t3td11'></td><td id='t3td12'></td><td id='t3td13'></td><td id='t3td14'></td><td id='t3td15'></td></tr>);                                        table3.append(<tr><td id='t3td16'></td><td id='t3td17'></td><td id='t3td18'></td><td id='t3td19'></td><td id='t3td20'></td></tr>);                                        table3.append(<tr><td id='t3td21'></td><td id='t3td22'></td><td id='t3td23'></td><td id='t3td24'></td><td id='t3td25'></td></tr>);                                        $(#bord3).fadeIn(slow);                                        $(#bord2).empty();                                        $(#bord1).empty();                                    }                                }                            } //EINDE GROTE ELSE                            $(td).one(click, function () { //X of O op de tabelen                                if (move === 0) {                                    $(this).text(x);                                    move === 1;                                    RandomMove1();                                    RandomMove2();                                }                            });                            // GEBRUIKER MOVE                            function UserMove() {                                if (table1.text() !== x && table1.text() !== o) {                                    table1.text(x);                                } else if (table2.text() !== x && table2.text() !== o) {                                    table2.text(x);                                } else if (table3.text() !== x && table3.text() !== o) {                                    table3.text(x);                                }                            };                            // CPU PLAYER MOVE                            // TABEL 1                            function RandomMove1() {                                if (random1 > 0.89) {                                    if ($(#t1td1).text() !== x && $(#t1td1).text() !== o) {                                        $(#t1td1).text(o);                                        return $(#t1td1).text(o);                                    } else if (random1 > 0.78) {                                        if ($(#t1td2).text() !== x && $(#t1td2).text() !== o) {                                            $(#t1td2).text(o);                                            return $(#t1td2);                                        } else if (random1 > 0.68) {                                            if ($(#t1td3).text() !== x && $(#t1td3).text() !== o) {                                                $(#t1td3).text(o);                                                return $(#t1td3);                                            } else if (random1 > 0.57) {                                                if ($(#t1td4).text() !== x && $(#t1td4).text() !== o) {                                                    $(#t1td4).text(o);                                                    return $(t1td4);                                                } else if (random1 > 0.48) {                                                    if ($(#t1td5).text() !== x && $(#t1td5).text() !== o) {                                                        $(#t1td5).text(o);                                                        return $(#t1td5);                                                    } else if (random1 > 0.38) {                                                        if ($(#t1td6).text() !== x && $(#t1td6).text() !== o) {                                                            $(#t1td6).text(o);                                                            return $(#t1td6);                                                        } else if (random1 > 0.26) {                                                            if ($(#t1td7).text() !== x && $(#t1td7).text() !== o) {                                                                $(#t1td7).text(o);                                                                return $(#t1td7);                                                            } else if (random1 > 0.15) {                                                                if ($(#t1td8).text() !== x && $(#t1td8).text() !== o) {                                                                    $(#t1td8).text(o);                                                                    return $(#t1td8);                                                                } else if (random1 > 0.08) {                                                                    if ($(#t1td9).text() !== x && $(#t1td9).text() !== o) {                                                                        $(#t1td9).text(o);                                                                        return $(#t1td9);                                                                    }                                                                }                                                            }                                                        }                                                    }                                                }                                            }                                        }                                    }                                }                            }                            // TABEL 2                            - function RandomMove2() {                                if (random2 > 0.99) {                                    if ($(#t2td1).text() !== x && $(#t2td1).text() !== o) {                                        $(#t2td1).text(o);                                        return $(#t2td1);                                    } else if (random2 > 0.88) {                                        if ($(#t2td2).text() !== x && $(#t2td2).text() !== o) {                                            $(#t2td2).text(o);                                            return $(#t2td2);                                        } else if (random2 > 0.80) {                                            if ($(#t2td3).text() !== x && $(#t2td3).text() !== o) {                                                $(#t2td3).text(o);                                                return $(#t2td3);                                            } else if (random2 > 0.77) {                                                if ($(#t2td4).text() !== x && $(#t2td4).text() !== o) {                                                    $(#t2td4).text(o);                                                    return $(t2td4);                                                } else if (random2 > 0.72) {                                                    if ($(#t2td5).text() !== x && $(#t2td5).text() !== o) {                                                        $(#t2td5).text(o);                                                        return $(#t2td5);                                                    } else if (random2 > 0.48) {                                                        if ($(#t2td6).text() !== x && $(#t2td6).text() !== o) {                                                            $(#t2td6).text(o);                                                            return $(#t2td6);                                                        } else if (random2 > 0.36) {                                                            if ($(#t2td7).text() !== x && $(#t2td7).text() !== o) {                                                                $(#t2td7).text(o);                                                                return $(#t2td7);                                                            } else if (random2 > 0.55) {                                                                if ($(#t2td8).text() !== x && $(#t2td8).text() !== o) {                                                                    $(#t2td8).text(o);                                                                    return $(#t1td8);                                                                } else if (random2 > 0.42) {                                                                    if ($(#t2td9).text() !== x && $(#t2td9).text() !== o) {                                                                        $(#t2td9).text(o);                                                                        return $(#t2td9);                                                                    } else if (random2 > 0.22) {                                                                        if ($(#t2td10).text() !== x && $(#t2td10).text() !== o) {                                                                            $(#t2td10).text(o);                                                                            return $(#t2td10);                                                                        } else if (random2 > 0.29) {                                                                            if ($(#t2td11).text() !== x && $(#t2td11).text() !== o) {                                                                                $(#t2td11).text(o);                                                                                return $(#t2td11);                                                                            } else if (random2 > 0.69) {                                                                                if ($(#t2td12).text() !== x && $(#t2td12).text() !== o) {                                                                                    $(#t2td12).text(o);                                                                                    return $(#t2td12);                                                                                } else if (random2 > 0.04) {                                                                                    if ($(#t2td13).text() !== x && $(#t2td13).text() !== o) {                                                                                        $(#t2td13).text(o);                                                                                        return $(#t2td13);                                                                                    } else if (random2 > 0.72) {                                                                                        if ($(#t2td14).text() !== x && $(#t2td14).text() !== o) {                                                                                            $(#t2td14).text(o);                                                                                            return $(#t2td14);                                                                                        } else if (random2 > 0.10) {                                                                                            if ($(#t2td15).text() !== x && $(#t2td15).text() !== o) {                                                                                                $(#t2td15).text(o);                                                                                                return $(#t2td15);                                                                                            } else if (random2 > 0.94) {                                                                                                if ($(#t2td16).text() !== x && $(#t2td16).text() !== o) {                                                                                                    $(#t2td16).text(o);                                                                                                    return $(#t2td16);                                                                                                }                                                                                            }                                                                                        }                                                                                    }                                                                                }                                                                            }                                                                        }                                                                    }                                                                }                                                            }                                                        }                                                    }                                                }                                            }                                        }                                    }                                }                            }   //TABEL 3
beginner TICTACTOE game for my school projet
javascript;beginner;tic tac toe